温度转换华氏python_Python程序将温度从摄氏温度转换为华氏温度,反之亦然

本文介绍如何使用Python编写程序,将温度从摄氏度转换为华氏度,反之亦然。提供了转换的公式以及相应的代码示例和输出结果。
摘要由CSDN通过智能技术生成

温度转换华氏python

Formula used:

使用的公式:

    
    Celsius to Fahrenheit:  °C= (5/9)*(°F-32)
    Fahrenheit to Celsius:  °F= (9/5)*(°C) + 32
     

Code:

码:

# Define a function to convert
# celsius temperature to Fahrenheit
def Celsius_to_Fahrenheit(c) :
    
    f = (9/5)*c + 32
    
    return f
    
# Define a function to convert
# Fahrenheit temperature to Celsius
def Fahrenheit_to_Celsius(f) :
    
    c = (5/9)*(f - 32)
    
    return c
    

# Driver Code
if __name__ == "__main__" :
    
    c = 36
    print(c, "degree celsius is equal to:",Celsius_to_Fahrenheit(c),"Fahrenheit")
    
    f = 98
    print(f,"Fahrenheit is equal to:",Fahrenheit_to_Celsius(f),"degree celsius")

Output

输出量

    36 degree celsius is equal to: 96.8 Fahrenheit
    98 Fahrenheit is equal to: 36.66666666666667 degree celsius


翻译自: https://www.includehelp.com/python/program-to-convert-temperature-from-Celsius-to-Fahrenheit-and-vice-versa.aspx

温度转换华氏python

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值