Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Per the program requirements in the comment section, I wanted to know to have someone review my code and see if there are any suggestions

Per the program requirements in the "comment section," I wanted to know to have someone review my code and see if there are any suggestions or comments. For instance, what if the high score, i.e. 10.0, is listed more than once. Do I need to somehow add this to my code?

## At certain Olympic events, there are 5 judges.

## To determine an athlete's final score for the event, ## the highest and lowest judges' scores are discarded ## and then the average of the rest of the scores is calculated. Assume that the ## array 'scores' contains the judges' scores.

## Write a function that accepts as an arguement a list ## of scores and returns the athlete's final score. ## ## (Hint: Add up all the scores in the array. Find the highest and lowest scores ## and subtract them out. Divide the sum by len(scores) - 2 and return the average.)

## ListScores = [5, 5, 5, 5, 5] ## ListScores = [0, 1, 2, 3, 4]

name = input("Enter athlete's last name: ") ListScores = [] size = len(ListScores) total = 0.0

def main(): total = 0 for score in range(1,6): while True: score = float(input("Enter athlete's score between 0 and 10: ")) if (score >= 0) and (score <= 10): break else: print("Invalid Score") ListScores.append(score)

for score in range(len(ListScores)): total += ListScores[score] print("Total Score:", ListScores,"=",total) print("Minimum Score:",min(ListScores), "Maximum Score:",max(ListScores))

def finalScore(finalScore): total = 0 minScore = ListScores[0] maxScore = ListScores[0] for score in ListScores: if (score < minScore): minScore = score for score in ListScores: if (score > maxScore): MaxScore = score

score = sum(ListScores) - (minScore + maxScore) return (score/3)

main() fs = finalScore(finalScore) print(name,"\tFinal Score: ",format(fs, '.2f'))

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions