完整的温度转换程序

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> while True:
  a = input('1:摄氏度转华氏度\n2:华氏度转摄氏度\n3:退出\n')
  if a =='1':
      celsius=float(input('输入摄氏度:'))
      fahrenheit=(celsius*9/5)+32
      print('{:.2f}摄氏度转化为华氏度{:.2f}'.format(celsius,fahrenheit))
  elif a =='2':
      fahrenheit=float(input('请输入华氏度:'))
      celsius=9/5*(f-32)
      print('{:.2f}华氏度转为摄氏度:{:.2f}'.format(fahrehheit,celsius))
  else:
      break

 

posted @ 2018-04-23 17:00  chenguanxun  阅读(851)  评论(0)    收藏  举报