Ask a yes-or-no question
A comparison such as t < 0.0 produces true or false. An if condition requires a boolean. The band function first checks for a value below zero. Its early return immediately sends the string frozen back to the caller.
Partition the remaining inputs
After the first check, every remaining input in this example is zero or warmer. The final if expression chooses mild below 30 and hot otherwise. Because this expression supplies the function’s result, there is no semicolon after its closing brace.
Read the comparison signs
Use == to compare for equality and != to test inequality. Use < or > for strict limits and <= or >= to include the limit itself. To combine rules, && requires both sides, || requires at least one, and ! reverses a boolean. Short-circuit evaluation skips the right side once the answer is known.
Test the boundary
Two implementations can agree on -2 and 10 and still disagree at zero. A boundary test deliberately uses the threshold itself. Here 0.0 skips the frozen branch and 30.0 skips the mild branch.
Try the program
Expected output
frozen mild hot
Practice
Change the rule so exactly 30 is mild. Keep the boundary at zero as it is.
Hint
Look for the comparison in the final if expression.
Worked solution
Including equality sends 30.0 through the mild branch. The negative and zero cases take their original branches.
Find
t < 30.0Replace with
t <= 30.0Output after the change
frozen mild mild