当前位置:天才代写 > tutorial > Python教程 > python 将华氏温度转换成摄氏温度,或者相反

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

2018-05-17 08:00 星期四 所属: Python教程 浏览:396

python">#-*- 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

 

    关键字:

天才代写-代写联系方式