条件语句,while循环语句:完整的温度转换程序
while True:
a = input('1:摄氏转华氏\n2: 华氏转摄氏\n3: 退出\n')
if a == '1':
celsius = float(input('输入摄氏温度:'))
fahrenheit = (celsius*9/5)+32
print('{:.2f}摄氏温度转为华氏温度为{:.2f}\n'.format(celsius,fahrenheit))
elif a == '2':
fahrenheit = float(input('请输入华氏温度:'))
celsius = 5/9*(fahrenheit-32)
print('{:.2f}华氏温度转换为摄氏温度为:{:.2f}\n'.format(fahrenheit,celsius))
else:
break
相关推荐
zhaobig 2020-08-17
TreasureZ 2020-08-02
NewActivity 2020-07-23
Jieen 2020-07-09
yawei 2020-07-06
AndroidAmelia 2020-05-17
fly00love 2020-05-16
zhuxianfeng 2020-05-17
银角大王 2020-05-11
joyjoy0 2020-05-09
伏雌摘星阁 2020-04-22
流云追风 2020-04-22
拉斯厄尔高福 2020-04-11
flycony 2020-04-10
致终将努力的我们 2020-04-08
xiaobater 2020-02-11
duanlove技术路途 2020-01-16
doubinning 2020-01-10
赵家小少爷 2020-01-04