好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

用python写温度转换

Python写摄氏温度转换为华氏温度:

celsius = float(input('输入摄氏温度: '))
 
# 计算华氏温度
fahrenheit = (celsius * 1.8) + 32
print('%0.1f 摄氏温度转为华氏温度为 %0.1f ' %(celsius,fahrenheit)) 

使用公式:

fahrenheit = (celsius * 1.8) + 32 

Python写华氏温度转换为摄氏温度:

fahrenheit = float(input('输入华氏温度: '))
 
# 计算摄氏温度
celsius = (fahrenheit - 32) / 1.8
print('%0.1f 华氏温度转为摄氏温度为 %0.1f ' %(fahrenheit,celsius)) 

公式:

celsius = (fahrenheit - 32) / 1.8 

以上就是用python写温度转换的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于用python写温度转换的详细内容...

  阅读:40次