完整的温度转换程序

while True:
  a = input('摄氏温度转化华氏温度请按1\n华氏温度转化摄氏温度请按2\n')
  if a =='1':
    c = float(input('请输入摄氏温度:'))
    f = c*9/5 + 32
    print('{:.2f}摄氏温度转换华氏温度为:{:.2f}'.format(c,f))      
  elif a=='2':
    f = input('请输入华氏温度:')
    c = 5/9*(float(f)-32)
    print('{}华氏温度转化摄氏温度为:{:.2f}'.format(f,c))
  else:
    break;

猜你喜欢

转载自www.cnblogs.com/FBYi/p/8920154.html
今日推荐