摂氏を華氏に変換するPythonプログラム

Python

以下のプログラムでは、摂氏で温度を取得し、華氏に変換します。 それらは次の式で関連付けられます。

celsius * 1.8 = fahrenheit - 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



Hope this helps!

Source link

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です