#温度转换程序
#TempConvert.py
val = input("Please input a number")
if val[-1] in ['C', 'c']:
f = 1.8 * float(val[0:-1]) + 32
print("temperature" % f)
elif val[-1] in ['F','f']:
c = (float(val[0:-1] - 32) / 1.8
print("temperature" % c)
else:
print("Error")
33个保留字:
定义变量时,不能与之相同~
| name | name | name | name |
|---|---|---|---|
| and | elif | import | raise |
| as | else | in | return |
| assert | except | is | try |
| break | finally | lambda | while |
| class | for | nonlocal | with |
| continue | from | not | yield |
| def | globall | or | True |
| del | if | pass | False |
| None |
这篇博客主要探讨了Python中进行温度转换的方法,包括华氏度转摄氏度和摄氏度转华氏度的实现,同时强调了在编程过程中需要注意的33个保留字,这些保留字在定义变量时不应使用。
2526

被折叠的 条评论
为什么被折叠?



