Module 2
else
What to do when the condition is false.
The other path
An if statement can be followed by an else. The else block runs when the condition is false.
Python
temperature = 25
if temperature > 30:
print("Too hot")
else:
print("OK")→ OK
Now the program has two paths. If the temperature is above 30, it prints Too hot. Otherwise, it prints OK. Exactly one of the two blocks runs.
Your task
Add an else clause
- If temperature is 25, print Warm when > 30, otherwise print Cool.