Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

ne analysis we might want to do is to compute an average of a set of numbers but with some outliers k values, where k

image text in transcribed
ne analysis we might want to do is to compute an average of a set of numbers but with some outliers k values, where k is some positive integer. Define a function named calc average excluding extremes() that removes a specfed number of outiers and returns an average of the remaining removed. A simple version of this analysis might 3 values, then compute an average of those that remain. We can generalize this to remove the smallest and values . It has two parameters - The first is a list of numeric values. .The second is an integer k . The function should return the average of the values that remain after removing or ignoring the smallest and largest k values from the given list [ ]: # Define the cale-average-excluding-extremes() function here. Tests below will run some tests on the calc average excluding extrenes() function you define above. It passes a variety of Executing the cell to the function. The expected return values for the first two are shown here, and you passing all of the tests. should think about what the others should be to verify that your functionis First two expected test outputs: list: (1, 2, 3] k: 1 return value: 2.e list: [1, 2, 3, 4, 5, 6] k: 2 return value: 3.s "]: # Tests for cole_average_excluding-extremes() [do not modify] test_list 1 (1, 2, 3) test_list 2 [1, 2, 3, 4, 5, 61 test list 3 [1, 1, 1, 9, 9, 9 2] test list 4 [s, 4, 3, 2, 1] ret - calc_average excluding extreses(test list 1:]. 1) print("1ist: k: return value: ()".format (repr (test list1), 1, ret)) ret calc average excluding extrenes(test list 2[:1. 2) print("list: ) return value: (.format (repr(test list 2), 2, ret)) 1243 AM

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

More Books

Students also viewed these Databases questions

Question

What are the relevant aspects of consumer behavior and product use?

Answered: 1 week ago