Determine_grade-接受单个数字作为参数,并根据以下评分标准显示分数的字母等级:Score 90-100 80-89 70-79 60-69 Below 60
Letter Grade A
B
C
D
Fcalc_average-以分数列表作为参数,显示分数的平均值,以及与该平均值相等的字母分数。
main-要求用户输入五个测试分数,并将它们作为数字放入列表中
showLetters–echo打印用户输入的分数和字母等级相等
按每个主要步骤写评论。下面是程序的运行示例:
输入等级:65、80、90、71、8565.0 is D
80.0 is B
90.0 is A
71.0 is C
85.0 is B
平均值是:78.2,也就是Cdef main():
enter code herescores = input("Enter five test scores seperated by commas:")
listScores = scores.split(",")`enter code here`
determine_grade(listScores)
calc_average(listScores)
def determine_grade(grades):
for num in grades:
if int(num) >= 90 and int(num) <= 100:
print("A")
elif int(num) >=80 and int(num) <= 89:
print("B")
elif int(num) >=70 and int(num) <= 79:
print("C")
elif int(num) >=60 and int(num) <= 69:
print("D")
else:
print("F")
def calc_average(grades):
total = 0
for num in grades:
total += int(num)
average = total / 5
print(average)
#def show_letters(values):
main()
这就是我目前所拥有的,但似乎还不知道如何格式化它?