Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create a function to get the k largest elements instead of the k smallest. The rest should be the same. Don't forget to add

 

create a function to get the k largest elements instead of the k smallest. The rest should be the same. Don't forget to add an appropriate docstring. To test your code, use the below main program: test [2,7,9,3,6,5,1,1,2,9] test2 [2,7,3,3] print("First test: ") print("Before function: ", test) print("Five largest: ", kMax(test, 5)) print("After function: ", test) print("Second test: ") print("Before function:",test2) print("Five largest: ", kMax (test2,5)) print("After function:",test2) You should then be able to get the following sample run: First test: Before function: [2, 7, 9, 3, 6, 5, 1, 1, 2, 9] Five largest: [5, 6, 7, 9, 9] After function: [2, 7, 9, 3, 6, 5, 1, 1, 2, 9] Second test: Before function: [2, 7, 3, 3] Five largest: [2, 3, 3, 7] After function: [2, 7, 3, 3] G

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

Essentials Of Business Analytics

Authors: Jeffrey Camm, James Cochran, Michael Fry, Jeffrey Ohlmann, David Anderson, Dennis Sweeney, Thomas Williams

1st Edition

128518727X, 978-1337360135, 978-1285187273

More Books

Students also viewed these Programming questions

Question

What does the term homoscedasticity mean?

Answered: 1 week ago