温度変換
摂氏、華氏、ケルビンの変換。
代表的な温度
温度コンバーターは、摂氏、華氏、ケルビン — 日常生活と科学的作業で最もよく使われる3つの温度スケール — 間で値を変換します。摂氏はほとんどの国と科学での標準、華氏はアメリカでの天気と日常の温度に使われ、ケルビンは0 Kが絶対零度を表す物理と化学で使用される絶対スケールです。
3つのフィールドのいずれかに温度を入力すると、他の2つが変換された値で即座に更新されます。使用される公式は正確で、°Cから°Fは(°C × 9/5) + 32、°CからKは°C + 273.15です。
国際的な天気予報の読み取り、科学論文の理解、外国語のレシピでの料理、実験室機器の設定など、様々な場面で温度変換が必要になります。
よくある質問
コード実装
# Temperature conversion functions
def celsius_to_fahrenheit(c: float) -> float:
return c * 9 / 5 + 32
def fahrenheit_to_celsius(f: float) -> float:
return (f - 32) * 5 / 9
def celsius_to_kelvin(c: float) -> float:
return c + 273.15
def kelvin_to_celsius(k: float) -> float:
return k - 273.15
def fahrenheit_to_kelvin(f: float) -> float:
return (f - 32) * 5 / 9 + 273.15
def kelvin_to_fahrenheit(k: float) -> float:
return (k - 273.15) * 9 / 5 + 32
# Examples
print(celsius_to_fahrenheit(100)) # 212.0 (boiling point)
print(celsius_to_fahrenheit(0)) # 32.0 (freezing point)
print(celsius_to_kelvin(0)) # 273.15 (absolute zero at -273.15°C)
print(fahrenheit_to_celsius(98.6)) # 37.0 (body temperature)Comments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.