Start New Discussion within our Software Development Community

I am needed to create a program that could be used by judges judging a diving competition, where there is 7 judges and the lowest and highest scores are removed and the average is then calculated. this is what i have so far however it does not work. Can anyone help. Thankyou.

def main():
    scoreCounter = 0
    diverName = raw_input ('Enter divers name:')
    degreeOfDifficulty= input ('Enter degree of difficulty')
    for scoreCounter in range(0,7,1):
        score = input ('enter score: ')
    if score < lowScore:
        lowScore = score
    elif score > highScore:
        highScore = score
    scoreCounter = scoreCounter + 1
    print 'lowscore = ', lowScore, 'highscore = ', highScore
    subTotal= subTotal + score
    totalResult= subTotal - lowScore - highScore
    totalResult = totalResult * degreeOfDifficulty * 3/5
    print '\n\n The final score for diver ', diverName,' is ',totalResult, '.'


Like this maybe. The list and sorting it makes it easy.

def main():
    diverName = raw_input('Enter divers name: ')
    degreeOfDifficulty = input('Enter degree of difficulty: ')
    scoreList = []
    for scoreCounter in range(1, 8):
        scoreList.append(input('Enter score %s: ' % scoreCounter))
    sortedScores = sorted(scoreList)
    print '\nhighscore = %s\nlowscore = %s' % (sortedScores[6], sortedScores[0])
    totalResult = 0
    for i in range(1, 6):
        totalResult += sortedScores[i]
    totalResult = totalResult * degreeOfDifficulty * 3/5
    print '\nThe final score for diver %s is %s.' % (diverName, totalResult)


Cheers and Happy coding

This article has been dead for over six months. Start a new discussion instead.