找到最低的测试分数和两个高分的平均值

Finding lowest test score and average of two high scores

我在作业中解决了所有其他问题,但我卡在了最后一步,这需要我找到最低的测试分数,然后显示最高的两个测试分数的平均值,并显示最低的测试分数。我知道我需要在 "def findAndReturnLowest" 下面添加一个 if/elif/else 函数,但我发现了错误。这是我应该做的屏幕截图 enter image description here

这是我的代码

def main():
    score1 = 0.0
    score2 = 0.0
    score3 = 0.0

    score1 = getTestScore()
    score2 = getTestScore()
    score3 = getTestScore()

    calcAvgAndDisplayResults(score1, score2, score3)

def calcAvgAndDisplayResults(s1, s2, s3):
    lowest = 0.0
    average = 0.0
    lowest = findAndReturnLowest(s1, s2, s3)
def findAndReturnLowest(s1, s2, s3):


    average = (s1+s2+s3-lowest)/2
    print("Average = ", average)

def getTestScore():
    test = 0.0
    test=float(input("Enter a test score between 0 and 100: "))
    return test

# start of program
main()

使用嵌套if:

def findAndReturnLowest(s1, s2, s3):
    if s1 > s3 and s2 > s3:
        return s3

    else:
        return s2 if s1 > s2 else s1

非常简单的方法应该可行,但有很多方法:

def main():
    score1 = 0.0
    score2 = 0.0
    score3 = 0.0

    score1 = getTestScore()
    score2 = getTestScore()
    score3 = getTestScore()

    calcAvgAndDisplayResults(score1, score2, score3)

def calcAvgAndDisplayResults(s1, s2, s3):
    lowest = findAndReturnLowest(s1, s2, s3)

def findAndReturnLowest(s1, s2, s3 ):
    lowest = min([int(x) for x in [s1,s2,s3]])
    average = (s1+s2+s3-lowest)/2
    print("Average = ", average)
    print("Lowest = ", lowest)

def getTestScore():
    test = 0.0
    test=float(input("Enter a test score between 0 and 100: "))
    return test

# start of program
main()