Python温度转换代码

tempstr = input("请输入带有符号的温度值:")
if tempstr[-1] in ['F','f']:
C = (eval(tempstr[0:-1]) - 32)/1.8
print("转换后的温度是{:.2f}C".format(C))
elif tempstr[-1] in ['C','c']:
F = 1.8*eval(tempstr[0:-1]) + 32
print("转换后的温度是{:.2f}F".format(F))
else:
print('输入的格式错误')
tempstr = input("请输入带有符号的温度值:")

if tempstr[-1] in ['F','f']:
    C = (eval(tempstr[0:-1]) - 32)/1.8
    print("转换后的温度是{:.2f}C".format(C))
elif tempstr[-1] in ['C','c']:
    F = 1.8*eval(tempstr[0:-1]) + 32
    print("转换后的温度是{:.2f}F".format(F))
else:
    print('输入的格式错误')
tempstr = input("请输入带有符号的温度值:") if tempstr[-1] in ['F','f']: C = (eval(tempstr[0:-1]) - 32)/1.8 print("转换后的温度是{:.2f}C".format(C)) elif tempstr[-1] in ['C','c']: F = 1.8*eval(tempstr[0:-1]) + 32 print("转换后的温度是{:.2f}F".format(F)) else: print('输入的格式错误')
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
Making the absolute best of ourselves is not an easy task. It is a pleasurable pursuit...but it requires patience, persistence, and perseverance.
做最好的自己并不容易,这是很美好的愿望,需要耐心、坚持和毅力
评论 抢沙发
头像
良言一句三冬暖 . 恶语伤人六月寒
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    暂无评论内容