创建列表以平均我的输出数字

时间:2016-01-14 15:29:49

标签: python list

我正在编写用于评分的代码,我有5个等级的用户输入,然后它会给他们成绩信。在5个输入结束时,我希望它显示学生的平均成绩点。

def grades():


    grade = int(raw_input("Enter the student's grade: "))

    A = 'A'
    B = 'B'
    C = 'C'
    D = 'D'
    F = 'F'
    if grade >= 90:
        print A
    elif grade >= 80:
        print B
    elif grade >= 70:
        print C
    elif grade >= 60:
        print D
    else: F

    grade = int(raw_input("Enter the student's second grade: "))

    A = 'A'
    B = 'B'
    C = 'C'
    D = 'D'
    F = 'F'
    if grade >= 90:
        print A
    elif grade >= 80:
        print B
    elif grade >= 70:
        print C
    elif grade >= 60:
        print D
    else: F

    grade = int(raw_input("Enter the student's third grade: "))

    A = 'A'
    B = 'B'
    C = 'C'
    D = 'D'
    F = 'F'
    if grade >= 90:
        print A
    elif grade >= 80:
        print B
    elif grade >= 70:
        print C
    elif grade >= 60:
        print D
    else: print F

    grade = int(raw_input("Enter the student's fourth grade: "))

    A = 'A'
    B = 'B'
    C = 'C'
    D = 'D'
    F = 'F'
    if grade >= 90:
        print A
    elif grade >= 80:
        print B
    elif grade >= 70:
        print C
    elif grade >= 60:
        print D
    else: print F

    grade = int(raw_input("Enter the student's fifth grade: "))

    A = 'A'
    B = 'B'
    C = 'C'
    D = 'D'
    F = 'F'
    if grade >= 90:
        print A
    elif grade >= 80:
        print B
    elif grade >= 70:
        print C
    elif grade >= 60:
        print D
    else: print F

grades()

任何和所有帮助将不胜感激。寻找成绩数字和平均成绩。

1 个答案:

答案 0 :(得分:1)

不确定问题是什么,不会为你编写代码,所以这里有一些简单的伪代码。

int average
for loop loops 5 times
    ask for each grade
    average += grade
average = average / times looped
check average against letter grade values
print average + letter grade

你已经掌握了大部分内容,所以我不确定你遇到的问题是什么。