方法1:使用完整的条件表达式
score = int(input("请输入分数:"))
grade = ''
if(score<60):
grade = "不及格"
if(60<=score<80):
grade = "及格"
if(80<=score<90):
grade = "良好"
if(90<=score<100):
grade = "优秀"
print("分数是{0},等级是{1}".format(score,grade))
方法2:利用多分支结构
score = int(input("请输入分数:"))
grade = ''
if score<60:
grade="不及格"
elif score<80:
grade="及格"
elif score<90:
grade="良好"
elif score<=100:
grade="优秀"
print("分数是{0},等级是{1}".format(score,grade))
拓展题:】输入一个分数。分数在 0-100 之间。90 以上是 A,80 以上是 B,70 以上是 C,60 以上是 D。60 以下是 E。
score = int(input("请输入一个在 0-100 之间的数字:"))
grade = ""
if score>100 or score&