用户:
烨烨小栗子查看:0 回复:0 评论:0 创建时间:2021-10-23T12:34:43
a = int(input('摄氏度 → 华氏度请按1\n华氏度 → 摄氏度请按2\n'))
while a != 1 and a != 2:
a = int(input('输入错误重新输入。\n摄氏度 → 华氏度请按1\n华氏度 → 摄氏度请按2\n'))
if a == 1:
c = float(input('输入摄氏度:'))
f = (c * 1.8)+32 # 计算摄氏度
print('%.1f摄氏度转化为华氏度为%.1f' % (c, f))
else:
f = float(input('输入华氏度:'))
c = (f - 32)/1.8 # 计算华氏度
print('%.1f华氏度转化为摄氏度为%.1f' % (f, c))