您的位置:首页 > 技术中心 > 其他 >

用python写温度转换

时间:2022-02-24 10:24

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写温度转换的详细内容,更多请关注gxlsystem.com其它相关文章!

热门排行

今日推荐

热门手游