Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE PLEASE PLEASE FOLLOW THE REQUIREMENTS. Other Chegg answerers haven't been following them and that automatically gives me the wrong answer. Additionally, use Python3 and

PLEASE PLEASE PLEASE FOLLOW THE REQUIREMENTS. Other Chegg answerers haven't been following them and that automatically gives me the wrong answer. Additionally, use Python3 and don't import any packages.

Requirements (2):

assert statements (write assert statements to prevent any input that may corrupt your code, including arguments in invalid type, and arguments that do not fit the logic.)

one-line list comprehension (your implementation should only return an expression that involves list comprehension. In other words, without the 79-character line length limit, your implementation should fit in exactly one line. Note that if this question also requires assert statements, or you need to declare magic numbers, they would not count as extra lines.)

Problem:

In many sports that involve multiple judges to give scores, you might have seen this scoring system: remove one highest score and one lowest score from all scores given to a player, and take the average score of the remaining as the final score. This approach is called truncated mean. It is a fairer scoring system since it removes the outliers and still summarizes the opinions of the majority.

Write a function that takes the scores of all players as keyword arguments (keyword: name, value: a list of nonnegative numeric scores), and returns the name of the player with maximum score after calculating the scores with the truncated mean scoring.

Notes:

  1. You can assume that at least 1 score list is passed in the function, and each score list will have at least 3 elements.

  2. If there are multiple highest scores or lowest scores in a score list, only remove one of them and keep the rest.

  3. If there are multiple best player candidates to return, return any of them.

  4. You may find the built-in functions sorted() useful when filtering out outliers, and max() useful when finding the maximum score.

def best_player(**player_scores):

"""

>>> best_player(marina=[9.6, 9, 9.8, 9.9], darren=[9.0, 9.5, 9.9],

... elvy=[10.0, 9.8, 10.0, 9.5, 9.6])

'elvy'

>>> best_player(sean=[100, 99.99, 100])

'sean'

>>> best_player(james=[3.8, 3.5, 3.2], colin=[4.0, 3.6, 3.0])

'colin'

"""

# YOUR CODE GOES HERE #

ANSWER TO THE EXPERT'S QUESTION

The assert statements can be on multiple lines, but the return statement should only be one line. You can split the line so that the code looks like:

[

adkjadhksaj

dasdasdas

]

and that would still be considered one line. Hope this helps!

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 Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

Use emotional appeals with a receptive audience.

Answered: 1 week ago

Question

How flying airoplane?

Answered: 1 week ago

Question

=+2 Why are international employment standards important to IHRM?

Answered: 1 week ago

Question

=+1 Why are local employment laws important to IHRM?

Answered: 1 week ago