下面是我为了学习而尝试的一个程序
print("Students_performance_Application")
x = raw_input("Enter your name : ")
dict{"Rajesh":"456","Ranjith":"500","Ram":"456"}
average=dict[x]/6
print("Your average is {}%".format(Average))
if Average > 90:
print(" Hello patron , your Grade is S ")
elif((Average < 90) and (Average >= 60)):
print(" Hello patron , your Grade is B ")
elif((Average < 60) and (Average > 40)):
print(" Hello patron , your Grade is C ")
else:
print(" Hello patron , you have to redo the exams ")
如您所见,我希望从用户那里获得输入,并将值传递给(average=dict[x]/6),然后在那里获得结果。 但即使我传递“Rajesh”或“Ranjith”作为输入值
我得到以下错误:
Traceback (most recent call last):
File "C:\Python27\results.py", line 5, in <module>
average=dict[x]/6
TypeError: unsupported operand type(s) for /: 'str' and 'int'
将字典中的分数设置为int object。出现此错误是因为试图用整数(
average=dict[x]/6
)除字符串对象相关问题 更多 >
编程相关推荐