在下面的程序中,我们将摄氏温度转换为华氏温度。它们之间通过以下公式相关:
fahrenheit = celsius * 1.8 + 32
源代码
# Python Program to convert temperature in celsius to fahrenheit
# change this value for a different result
celsius = 37.5
# calculate fahrenheit
fahrenheit = (celsius * 1.8) + 32
print('%0.1f degree Celsius is equal to %0.1f degree Fahrenheit' %(celsius,fahrenheit))
输出
37.5 degree Celsius is equal to 99.5 degree Fahrenheit
我们鼓励您使用以下公式自行创建一个 Python 程序,将华氏温度转换为摄氏温度:
celsius = (fahrenheit - 32) / 1.8
另请阅读