模块化python测试等级

时间:2016-10-24 02:00:53

标签: python modular

所以到目前为止我的代码是

def main():

     grade1=int(input('Enter test score: '))
     grade2=int(input('Enter test score: '))
     grade3=int(input('Enter test score: '))
     grade4=int(input('Enter test score: '))
     grade5=int(input('Enter test score: '))

     average = calc_average(grade1,grade2,grade3,grade4,grade5)
     print('Your average score is ', average)




def calc_average(grade1,grade2,grade3,grade4,grade5):

    average_score = (grade1+grade2+grade3+grade4+grade5)/5
    return average_score

def determine_grade(score):

    if 90 <= grade <= 100:
        return 'A'      
    elif 80 <= grade <= 89:
        return 'B'
    elif 70 <= grade <= 79:
        return 'C'
    elif 60 <= grade <= 69:
        return 'D'
    else:
        return 'F'

main()

我现在卡住了,因为我需要输出看起来像这样:

Enter test score: 90
The letter grade is: A
Enter test score: 80
The letter grade is: B
Enter test score: 70
The letter grade is: C
Enter test score: 60
The letter grade is: D
Enter test score: 50
The letter grade is: F
The average is: 70.0

idk如何在输入每个测试分数后显示字母等级。任何人都可以帮我一把吗?

0 个答案:

没有答案