test.py

# 我的第一个小程序
print("今天的温度及相关判断\n")

i = 0
while 1:
i = i + 1

temperature = input("\n请输入今天的温度,或者q退出程序:")
if temperature == "q":
print("退出喽!")
break

try:
temperature = int(temperature)
except:
print("请重新输入整数!")
continue

if temperature <= -273:
print("瞎掰!宇宙中没有这样的温度哦")
continue
elif temperature <= -88:
print("貌似这比地球上最冷的天气还冷了!南极最低才-88度!")
elif -88 < temperature <= 0:
print("今天的天气好冷啊!这里是漠河吧")
elif (temperature >= 33) & (temperature < 6000):
print("今天的天气好热啊!")
elif 999999999 > temperature >= 6000:
print("wa!已经比太阳表面温度还高了")
# elif temperature >= 99999999:
# print("热核爆炸来了!")
else:
print("今天的天气很舒适!")
# 输入一个极大的数字试一试……

# print("第" + str(i) +"次循环结束")

if abs(temperature) >= 88:
displayStars = 88
else:
displayStars = abs(temperature)

# for temp in range(1,displayStars+1):
# if temperature < 0:
# print("*",end="")
# else:
# print("\033[0;31;40m*\033[0m",end="")

if temperature < 0:
print("*" * displayStars)
else:
print("\033[0;31;40m*\033[0m" * displayStars)

猜你喜欢

转载自www.cnblogs.com/augustone/p/11329629.html