# 流程控制
# 单分支
today_weather="rainday"
if today_weather=="rainday":
print("take your unberate")
#双分支
age_of_oldboy=58
if age_of_oldboy>50:
print("too old")
else:
print("too young")
# python 通过缩进来判断代码块。,同样层级代码,缩进一致,顶级代码定行写,官方建议四个空格是缩进
#多分支
score=89
if score<60:
print("不合格")
elif score <80:
print("合格")
elif score<90:
print("一般般")
else:
print("niubility")
练习题
ABCDE
A 90-100
B 80-89
C 70-79
D 60-69
E 0-59
while 1:
fenshu=int(input("请输入你的成绩:"))
if fenshu>=90 and fenshu<100:
print("得分a")
elif fenshu>=80 and fenshu<90:
print("得分b")
elif fenshu>=70 and fenshu<80:
print("得分c")
elif fenshu>=60 and fenshu<70:
print("得分d")
else:
print("得分e")
# 猜随机数小程序
import random
n=random.randint(1,10)
print(n)
while 1:
user_guess=int(input("请输入:"))
if user_guess>n:
print("太大了")
elif user_guess<n:
print("太小了")
else:
print("niubility")