Question #6 [15 pts]: Character Counter Using Higher-Order F…

Question #6 [15 pts]: Character Counter Using Higher-Order Function Write a higher-order function count(ch) that takes a single character ch as its input and returns another function. The returned function should take a string s and return the number of times ch appears in s. >>> count(‘s’)(‘mississippi’) 4 >>> count(‘z’)(‘hello’)       0 >>> count(‘x’)(‘example text’) 2

QUESTION #5 [15 pts]: Write the Python code to implement the…

QUESTION #5 [15 pts]: Write the Python code to implement the function largest_2(num_list). This function takes a non-empty list of numbers and returns the two largest elements in num_list in linear time (worse case runtime is O(n), where n is the size of num_list). The two largest values can be arranged in any order. You can assume num_list has at least three elements. Remember that if a function has a runtime of O(2n), it is considered O(n) . To get the most partial credit for this question, we recommend including the runtime of each line you write.   >>> largest_2([9, -1, 8, 7, 6, 8, 0]) (9, 8) >>> largest_2([7, 5, 1, 0, 3, 7, 9, 12, 7, 82]) (82, 12)