Weather ENUM

Report a typo

Write a Python function get_temperature() that takes in a temperature in degrees Celsius and returns the corresponding temperature mode in the Temperature enum.

The function should return:

  • Temperature.FREEZING if the temperature is below -5 degrees Celsius
  • Temperature.COLD if the temperature is between -5 and 10 degrees Celsius (inclusive)
  • Temperature.MODERATE if the temperature is between 11 and 25 degrees Celsius (inclusive)
  • Temperature.WARM if the temperature is between 26 and 35 degrees Celsius (inclusive)
  • Temperature.HOT if the temperature is above 35 degrees Celsius

Sample Input 1:

15

Sample Output 1:

MODERATE
Write a program in Python 3
from enum import Enum

class Temperature(Enum):
FREEZING = -10
COLD = 0
MODERATE = 20
WARM = 30
HOT = 40

def get_temperature(t):
pass

print(get_temperature(int(input())))
___

Create a free account to access the full topic