课后作业,只差输入为小写字母e时,程序停止未实现。
"成绩评级"counts = 0
counts = counts + 1
while counts >= 0:
score = input("请输入你的分数:")
score = int(score)
if score == 100:
print("S")
else:
if 90 <= score <100:
print("A")
else:
if 80 <= score <90:
print("B")
else:
if 60 <= score <80:
print("C")
else:
if 0 <= score <60:
print("D")
else:
break
输入分数在0-100以内,可以正常运行。其他整数均自动停止。 counts = 0
counts = counts + 1
while counts >= 0:
score = input("请输入你的分数:")
if score == 'e': # 在把score转化为整数前判断,因为'e'转化为整数会报错
break
score = int(score)
if score == 100:
print("S")
else:
if 90 <= score <100:
print("A")
else:
if 80 <= score <90:
print("B")
else:
if 60 <= score <80:
print("C")
else:
if 0 <= score <60:
print("D")
else:
break isdkz 发表于 2022-2-12 21:34
谢谢带佬,鱼C因你更精彩! 会翻身的咸鱼_ 发表于 2022-2-12 21:42
谢谢带佬,鱼C因你更精彩!
不客气,实不相瞒,我都是为了技术值{:5_109:}
页:
[1]