Question: Write a function called trimmed_mean(nums, trim) that takes in a list of numbers (you may assume that the input is valid!), and an optional integer
Write a function called trimmed_mean(nums, trim) that takes in a list of numbers (you may assume that the input is valid!), and an optional integer keyword argument trim (that takes on values of 0 or larger).
This function:
Removes the trim largest and smallest numbers from that list.
returns the arithmetic mean of whatever is left.
By default, trim = 1.
Example
trimmed_mean([2, 3, -100, 50000, 4]) would return 3, because 50000 and -100 are removed, and the mean of [2, 3, 4] is 3.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
