我正在开发一个班级程序,该程序会找到 5 个输入的测试分数的平均值,然后显示与每个字母分数相关的字母等级。字母分数是 10 分制(A = 90-100 B = 80-89 等)
到目前为止,这是我汇总的内容,但它似乎无法识别语法中的“avg”。有什么建议么?
def main():
while true:
grade = int(input('Enter grade: '))
total += grade
avg = calc_average(total)
abc_grade = determine_grade(grade)
print('Average grade is: ' avg)
print('Letter grades for entered grades are: ' abc_grade)
def calc_average(total):
return total / 5
def determine_grade(grade):
if grade >= 90 and <= 100:
return 'A'
elif grade >= 80 and <= 89:
return 'B'
elif grade >= 70 and <= 79:
return 'C'
elif grade >= 60 and <= 69:
return 'D'
else:
return 'F'
main()