34.7k views
4 votes
A talent competition has 5 judges, each of whom awards a score between 0 and 10 for each performer. Fractional scores, such as 8.3, are allowed. A performer’s final score is determined by dropping the highest and lowest score received, then averaging the three remaining scores. Write a program that uses this method to calculate a contestant’s score.

1 Answer

4 votes

Answer:

Follows are the code to this question:

def Contestant_Score(l):#defining a method Contestant_Score that accepst a list

mi=min(l)#defining mi variable that use min method to hold Lowest value

ma=max(l)#defining ma variable that use max method to hold highest value

y=sum(l)#defining y variable that hold sum of list

x=y-(mi+ma)#defining x variable that exclude mi and ma value

print("Lowest score: ", mi)#print Lowest score

print("highest score: ", ma)#print highest score

print("Calculating average excluding highest and Lowest number: ",x/3)#print average value

l=[9,5,7,4,6]#defining an empty list

Contestant_Score(l)#calling method

Output:

Lowest score: 4

highest score: 9

Calculating average excluding highest and Lowest number: 6.0

Explanation:

In the given code a method "Contestant_Score" is defined that accept a list in its parameter and inside the method three variable "mi, ma, and y" is defined, that uses the "min, max, and sum" to hold a value in a variable.

  • In the next step, x variable is defined that exclude the "mi and ma" value from y and calculate its average value and use the print method to print its value.
  • Outside the method, a list is defined that holds some value and pass into the method.
User Mateuscb
by
6.0k points