1. (8 points) a. Given the following program which uses the built-in filter function to select elements of a list n (see

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1. (8 points) a. Given the following program which uses the built-in filter function to select elements of a list n (see

Post by answerhappygod »

1 8 Points A Given The Following Program Which Uses The Built In Filter Function To Select Elements Of A List N See 1
1 8 Points A Given The Following Program Which Uses The Built In Filter Function To Select Elements Of A List N See 1 (48.49 KiB) Viewed 35 times
1. (8 points) a. Given the following program which uses the built-in filter function to select elements of a list n (see below in the program), complete the program by: (1) define a function myfune which take a list argument and check if the median of the list is greater than 5. Then use the function as a parameter of the filter function to filter all elements of n that have median greater than 5; (2) defining a lambda and use it in filter as the parameter to filter all list elements with mean greater than 10. After that, print the result. import math import statistics n-[[1, 3, 5, 8, 7, 6, 10], [2, 4, 6, 8, 9, 10], [12, 15, 18, 19, 20]] # list of lists def myfunc( a ): median_result filter( mean_result-filter( n) n) #apply median to each element in n #apply lambda to each element in n print( b. Complete the set_operation function in the following program: assume the three parameters a, b, and c are sets of student names (i.e., string type) from three different courses: Algebra, Biology, and CS1, respectively. Using set operation to find: (1) how many students are taking either Algebra or Biology, but not both; (2) how many are taking all three courses; (3) which course has the smallest enrollment? What is the class size difference between the largest one and the smallest one? import math def set_operation(a, b, c): # a, b, c are sets of strings, c.g., a {"Peter", "John"}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply