|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import random
score=random.randint(1,100)
temp=input("请输入分数")
score=int(temp)
while score != 0:
temp==input('请继续输入')
score=int(temp)
if 100 >= score > 90:
print('A')
else:
if 90 >= score >80:
print('B')
else:
if 80 >= score >70:
print('C')
else:
if 70 >= score >=60:
print('D')
else:
print('不及格')
我想要进行多次分数的录入并且划分等级,但是运行之后,一直重复循环出现:请输入分数40
请继续输入40
不及格
请继续输入78
不及格
请继续输入60
不及格
请继续输入70
不及格
请继续输入。去掉while语句的时候就是正常的,请问这个while语句哪边有问题呢?
import random
score=random.randint(1,100)
这个地方这个没啥作用,因为这个是取随机数的~而且你这重新赋值也覆盖了之前的 score
还有这里的写法是错误的,赋值一个等号,判断 == 等号:
改成这样就好了:
- temp=input("请输入分数")
- score=int(temp)
- while score != 0:
- if 100 >= score > 90:
- print('A')
- else:
- if 90 >= score >80:
- print('B')
- else:
- if 80 >= score >70:
- print('C')
- else:
- if 70 >= score >=60:
- print('D')
- else:
- print('不及格')
- temp = input('请继续输入')
- score = int(temp)
复制代码
|
|