多分支结构
并列式多分支结构
"""
功能:并列式多分支结构
作者:CXF
时间:2021年11月4日
"""
score =float(input('score ='))
level = ''
if score > 100:
level = '超出范围'
if score >= 90 and score <= 100:
level = '优秀'
if score >= 80 and score < 90 :
lecel = "良好"
if score >= 70 and score < 80:
level = '中等'
if score >= 60 and score < 70:
level = '及格'
if score >= 0 and score < 60:
level = '不及格'
if score < 0:
level = '超出范围'
print('等级为{}'.format(level))
嵌套式多分支结构
"""
功能:嵌套式多分支结构
作者:CXF
时间:2021年11月4日
"""
score =float(input('score ='))
level = ''
if score > 100:
level = '超出范围'
else:
if score >=90:
level = "优秀"
else:
if score >= 80:
level = "良好"
else:
if score >= 70:
level ="中等"
else:
if score >= 60:
level ="及格"
else:
if score >=0:
level = "不及格"
else:
level ="超出范围"
print('等级为{}'.format(level))
延拓式多分支结构
"""
功能:延拓式多分支结构
作者:CXF
时间:2021年11月4日
"""
score =float(input('score ='))
level = ''
if score > 100:
level = "超出范围"
elif score >= 90:
level = "优秀"
elif score >= 80:
level = "良好"
elif score >= 70:
level = "中等"
elif score >= 60:
level = "及格"
elif score >= 0:
level = "不及格"
else:
level = "超出范围"
print('等级为{}'.format(level))