Basic usage and conversion
Input
t = SafeTemperature(0) (t.celsius, t.fahrenheit)
Output
(0, 32.0)
Creating with 0°C stores 0 in celsius; fahrenheit returns 32.0.
Full lesson preview
Learn to enforce value constraints with a Python property setter, using a private attribute and clear error types/messages.
Problem statement
Task
Examples
Input
t = SafeTemperature(0) (t.celsius, t.fahrenheit)
Output
(0, 32.0)
Creating with 0°C stores 0 in celsius; fahrenheit returns 32.0.
Input format
Output format
Constraints
Samples
Input
SafeTemperature(100).fahrenheit
Output
212.0
100°C equals 212.0°F.