【发布时间】:2020-06-11 16:43:12
【问题描述】:
使用会提示的列表、函数和循环编写 Python 程序 用户以整数形式输入温度。您的程序将打印“它 如果温度超过 100,则“很热”,如果温度超过 100,则“很冷” 60以下,如果温度在61到99之间,“正好” 包括的。该程序继续询问温度,并且 如上所述评估它们,直到用户输入温度 0(到 退出程序)。显示了预期程序的示例 下面:
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!
temp = int(input("Enter the temperature: "))
while temp != 1:
if temp >= 100:
print ("It is hot")
elif temp <= 60:
print ("It is cold")
elif temp == 0:
print ("Good bye")
else:
print ("It is just right")
【问题讨论】:
标签: python