Building a temperature-based weather descriptor

Report a typo

You are building a weather application in Python. Your task is to display weather descriptions based on different temperature ranges. You'll need to fill the blanks in the code such that when the temperature exceeds 40 degrees, it should print 'It's very hot outside!', when the temperature is between 20 and 40, it should print 'The weather is nice.', and when the temperature is under 20, it should print 'It's cold outside'. Carefully study the control flow to correctly execute the desired output.

Fill in the gaps with the relevant elements
temperature = 30

 temperature > 40:
    print("It's very hot outside!")
 temperature > 20:
    print("The weather is nice.")
:
    print("It's cold outside.")
ifelifelse

Create a free account to access the full topic