Write a Python program using lists, function and loops that will prompt a user to enter a temperature as an integer. Your program will print "it is hot" if the temperature is over 100, "it is cold" if the temperature is under 60, and "it is just right" if the temperature is between 61 and 99 inclusive. The program continues to ask for temperatures, and evaluates them as above, until the user enters a temperature of 0 (to exit the program). An example of the anticipated program is shown below: Please enter a temperature: 95 It is just right. Please enter a temperature: 110 It is hot. Please enter a temperature: 32 It is cold. Please enter a temperature: 0 Good bye!
output = ['It is hot', 'It is cold', 'It is just right', 'Good bye']
def temp():
t= int(input('Please Enter temperature:'))
if t >100:
result = output[0]
elif t == 0:
print(output[3])
exit()
elif t < 60:
result= output[1]
else:
result = output[2]
print (result)
while True:
temp()
Comments
Leave a comment