Python 学校成绩评定员

Python 学校成绩评定员,python,Python,我试着写一个代码,你只需输入你的测试分数(满分100分),它就会给你一个分数(a、B、C、D等等)。然而,由于某种原因,我写的代码在给它一个随机数时给了我错误的分数。例如,我输入6,它给我一个D(而不是U)。 这是我的密码: score=int(input("What score did you get on your test?")) if int(0)>=score<=int(39): print ("You have got a U in your test."

我试着写一个代码,你只需输入你的测试分数(满分100分),它就会给你一个分数(a、B、C、D等等)。然而,由于某种原因,我写的代码在给它一个随机数时给了我错误的分数。例如,我输入6,它给我一个D(而不是U)。 这是我的密码:

score=int(input("What score did you get on your test?"))

if int(0)>=score<=int(39):   
    print ("You have got a U in your test.")
elif int(40)>=score<=int(49):    
    print ("You have got a D in your test.")
elif int(50)>=score<= int(59):  
    print ("You have got a C in your test.")
elif int(60)>=score<= int(69):    
    print ("You have got a B in your test.")
else:
    ("You have got an A in your test, well done!")
score=int(输入(“你在考试中得了多少分?”)

如果int(0)>=score=score=score你的不等式是不正确的。目前,U的条件是

if score is smaller than 0 and smaller than 39
应该是

if score is greater than 0 and smaller than 39
所以


你的不平等是不正确的。目前,U的条件是

if score is smaller than 0 and smaller than 39
应该是

if score is greater than 0 and smaller than 39
所以


您不需要
int(39)
所有这些数字,它们已经是int文本。最后一行可能应该有一个
print
。您不需要
int(39)
所有这些数字,它们已经是int文本。最后一行可能应该有一个
print
@GrijeshChauhan,字面上刚刚添加了这些:)@GrijeshChauhan,字面上刚刚添加了这些:)