温度换算
摄氏度、华氏度和开尔文之间的换算。
常见温度
温度转换器在摄氏度、华氏度和开尔文之间转换值——这是您在日常生活和科学工作中最可能遇到的三种温度标度。摄氏度是大多数国家和科学中的标准,华氏度用于美国的天气和日常温度,开尔文是物理和化学中使用的绝对标度,其中 0 K 代表绝对零度。
在三个字段中的任何一个输入温度,其他两个立即更新为转换值。使用的公式是精确的:°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.