grade = 0.0
grade = input("Please enter your gpa")
def grade_give(grade):
if grade > 0.9:
print("A")
elif grade > 0.8 and grade < 0.9 :
print("B")
elif grade >0.7 and grade < 0.8:
print ("C")
elif grade >0.6 and grade <0.7:
print ("D")
elif grade >0.5 and grade <0.6:
print ("E")
elif grade >0.4 and grade <0.3:
print ("F")
else:
print("Bad score")
grade_give(grade)
出现的错误是grade_give中的文件“/Users/pradyu/Desktop/py.py/function.py”,第4行 如果等级&gt; 0.9: TypeError:'&gt;' 'str'和'float'的实例之间不支持
答案 0 :(得分:1)
输入的输入是一个字符串。将其转换为浮动。
FILE * binfile = fopen("b2.bin", "rb");
或在函数
中执行此操作grade = input("Please enter your gpa")
grade = float(grade)
#carry on