Temperature Check
Programming Basics · Python
TASK
Problem
Given temperature `t`, print `FREEZING` if `t < 0`, `NORMAL` for `0 ≤ t ≤ 30`, and `HOT` for `t > 30`.
EXAMPLE
Example
31
HOT
LIMITS
Constraints
All floating-point inputs are finite and have absolute value at most 10^9.
LEARN
Theory for this problem
+
`input()` reads data entered by the user. The result of `input()` is initially a string. `float()` converts a numeric string into a number that may contain a decimal part. Comparison operators `==`, `!=`, `<`, `>`, `<=`, `>=` compare values and produce `True` or `False`. `if` checks a condition and runs its block when the condition is true. `else` runs when the corresponding `if` condition is false. `print()` displays the program result. Print only what the problem statement requires.
**Connection to this task.** An `if` statement chooses a program branch from a Boolean condition. Comparisons produce `True` or `False`, and `elif` lets you test several mutually exclusive cases in order. The expression `'FREEZING'` shows how this idea is applied to the task data.
NEED HELP?
Hints
+
['After checking `t < 0`, checking `t <= 30` is enough.']
ANSWER
Solution
+
t = float(input())
if t < 0:
print('FREEZING')
elif t <= 30:
print('NORMAL')
else:
print('HOT')