温度转换(python笔记)

#温度转换程序
#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)