我得到的输出是: 你的成绩是X 没有 我似乎无法弄清楚如何摆脱一切。
def computegrade (scr):
score = float (scr)
if score >= 0.9 :
print ("Your grade is A")
elif score >= 0.8 :
print ("Your grade is B")
elif score >= 0.7 :
print ("Your grade is C")
elif score >= 0.6 :
print ("Your grade is D")
elif score < 0.6 :
print ("Your grade is F")
else :
print ("Enter digits you moron")
scr = input("What was your score?\n")
print (computegrade (scr))
答案 0 :(得分:2)
您需要一个return
语句才能从函数实际返回值。在这里,您只print
,因此实际上不返回任何内容。
只需将您的print()
替换为return
,例如return "Your grade is F"
,您就会好起来的。