age = 9
if age >= 18:
print('teenager')
elif age >= 6:
print('adult')
else:
print('kid')
若x是非零值、非空字符串、非空List等,就判为True
s = input("birth:")
birth = int(s)
if birth < 200:
print('00前')
else:
print('00后')
input()反回str类型,用int(s)强制类型转换
names = ['Michael','Bob','Tracy']
for name in names:
print(name)
sum = 0
for x in list(range(101)):
sum = sum + x
print(sum)
网友评论