降低最低考试成绩

时间:2017-07-11 01:22:57

标签: python

我正在编写一个python程序,它降低了四个测试分数中的最低分。程序首先提示用户输入他们的前四个测试分数,然后程序应该降低最低测试分数并取其余三个测试分数的平均值。然后该程序应打印最终的字母等级。这是我到目前为止所做的事情,并且在降低最低分时我一直收到错误。

#Enter four test scores as percentages (%)
test1 = int(input("Enter grade 1: 90"))
test2 = int(input("Enter grade 2: 80"))
test3 = int(input("Enter grade 2: 70)")
test4 = int(input("Enter grade 2: 80)")

#Drop lowest test score
    print("The average, with the lowest score dropped" )
    total =(test1 + test2 + test3)

#Calculate average
        def calc_average(total):
        return total /3


#Grade scale
def determine_score(grade):
    if score >= 90:
        grade = "A"
    elif score >= 80:
        grade = "B"
    elif score >=70:
        grade = "C"
    elif score >= 60:
        grade = "D"
    else:
        grade = "F"

#Calculate final letter grade
print("The final grade is")


main()

1 个答案:

答案 0 :(得分:1)

我试着用你理解的东西写一个程序。 以下是解释:

从用户那里取四个等级。 降低最低的一个。 取平均值。 根据平均值给出一个字母等级。

以下是代码:

test1 = int(input("Enter grade 1: "))
test2 = int(input("Enter grade 2: "))
test3 = int(input("Enter grade 3: "))
test4 = int(input("Enter grade 4: "))

x = min(test1,test2,test3,test4)

total = float(test1 + test2 + test3 + test4 - x)

avg = total / 3

print("Your average is " + str(avg))


def determine_letter(grade):
    letter =""
    if grade >= 90:
        letter = "A"
    elif grade >= 80:
        letter = "B"
    elif grade >= 70:
        letter = "C"
    elif grade >= 60:
        letter = "D"
    else:
        letter = "F"

    print("The final letter grade is " + letter)


determine_letter(avg)