将华氏温度转换成摄氏温度,或者相反

2014-10-31 0 456
将华氏温度转换成摄氏温度,或者相反
#-*- charset:utf-8 -*-
#This program will follow users intention to convert F to C or the contray

typeNo = eval(input("Do you want to convert Fah to Cel or convert Cel to Fah,enter 1 for F to C,enter 2 for C to F:"))

if typeNo == 1:
    data = eval(input("Please enter your data:"))
    c = (data - 32) * 5 / 9
    print(data,"Fahrenheit to Celsius is:",round(c,1)," C")
elif typeNo == 2:
    data = eval(input("Please enter your data:"))
    f = data * 9 / 5 + 32
    print(data,"Celsius to Fahrenheit is:",round(f,1)," F")
elif (typeNo != 1) and (typeNo != 2):
    print("Input error!")

遇见资源网 python 将华氏温度转换成摄氏温度,或者相反 http://www.ox520.com/14846.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务