|
- #已知公式c=5/9(F-32)
- def fahrenheit_to_celsius(fahrenheit):#华氏温度转摄氏温度,
- celsius = round((fahrenheit-32)/1.8,2)
- return celsius
- def celsius_to_fahrenheit(celsius):#摄氏温度转华氏温度
- fahrenheit = round(celsius*1.8+32,2)
- return fahrenheit
- if __name__ == "__main__":
- c = fahrenheit_to_celsius(0)
- f = celsius_to_fahrenheit(-16.11)
- print(' 华氏:'+str(c),'\r\n','摄氏:'+str(f))
复制代码 |
|