一、判断语句
如果某些条件满足,才能做某件事情,而不满足时不允许做,这就是所谓的判断
if-else语句
age = 19
if age > 18:
print('已成年....')
else:
print('未成年....')
elif语句
score = 77
if score>=90 and score<=100:
print('本次考试,等级为A')
elif score>=80 and score<90:
print('本次考试,等级为B')
elif score>=70 and score<80:
print('本次考试,等级为C')
elif score>=60 and score<70:
print('本次考试,等级为D')
elif score>=0 and score<60:
print('本次考试,等级为E')
if嵌套
chePiao = 1 # 用1代表有车票,0代表没有车票
daoLenght = 9 # 刀子的长度,单位为cm
if chePiao == 1:
print("有车票,可以进站")
if daoLenght < 10:
print("通过安检")
print("终于可以见到Ta了,美滋