流程控制

if ... else

单分支

age = 19

if age >= 18 :

    print("成年了!")

双分支

age = 17
if age >= 18 :
    print("成年了!")
else :
    print("未成年!")

多分支

score = 60
if 90 <= score <= 100:
    print("A")
elif 80 <= score <= 89:
    print("B")
elif 60 <= score <= 79:
    print("C")
elif 40 <= score <= 59:
    print("D")
elif 0 <= score <= 39:
    print("E")
else:
    print("输入有误,请重新输入")

你可能感兴趣的:(流程控制)