用 python编写华氏摄氏度的相互转换
# - * - 编码:utf -8 - * - select = int(raw_input('select:\ t1 .celsius to fahrenheit \ t2 .faterheit to celsius \ n'))选择== 1 或select == 2 :tem = tem = tem = tem = tem = RAW_INPUT('请输入温度转换:\ n')2 和TEM <-4 5 9 .6 7 :YES:%。2 F'异常:打印'tem错误! 否则:请选择“选择错误!” >>摄氏。
2 F。
输入要转换的温度:转换后的温度为1 00如下。
3 7 .7 8
如何用 python编写华氏摄氏度的相互转换?
虽然是正确的:d = raw_input('请输入:')。f'Elif d [0] =='e':显示Celsius,“ 1 5 f”表示华氏,“ E”循环
如何用 python编写华氏摄氏度的相互转换?
华氏和摄氏的转换关系是,℉= 9 ×/5 +3 2 或℃= 5 ×(℉-3 2 )/9 ,最后一个位是一点“ C”,表示输入是C的输出。例如,输入为:'3 0 .1 c','8 6 f'。
def temptransform(temptr):tempval = tempstr [:-1 ] test:tempval = float(tempval)值:valueError:增加贵重者(“无效温度值”。
:tempval =(tempval-3 2 )*5 /9 返回'{} c'.format(tempval)elif tempunit =='c':tempval = tempval*9 /5 +3 2 返回'{} f'