III. Friday problems on while and for loops A. Another for loop example ------------------------------------------ FOR YOU TO DO Using a for loop, write a function product(lst), of type: list(number) -> number that returns the product of all the numbers in lst. The following are examples: assert product([]) == 1 assert product([2,3]) == 6 assert product([1,2,3,4]) == 1 * 2 * 3 * 4 assert product([10,5,1]) == 50 assert product([3,2,2,3]) == 9 * 4 assert product([10] + [3,2,2,3]) == 10*9*4 ------------------------------------------ B. An example where continue may be used in a for loop ------------------------------------------ FOR YOU TO DO Using a for loop and continue, write a function sumReciprocals(lst) of type: list(number) -> float that returns the sum of the numbers 1/x for all x in lst that are not zero. The following are examples: from math import isclose assert isclose(sumReciprocals([]), 0.0) assert isclose(sumReciprocals([0]), 0.0) assert isclose(sumReciprocals([1,0]), 1.0) assert isclose(sumReciprocals([1,2,0]), 1/1 + 1/2) assert isclose(sumReciprocals([3,2,2,3]), 1/3 + 1/2 + 1/2 + 1/3) assert isclose(sumReciprocals([3,0,2,0,0,2,0,3,0]), 1/3 + 1/2 + 1/2 + 1/3) ------------------------------------------ C. An example with less direction ------------------------------------------ FOR YOU TO DO Without using the ** operator of Python or recusrion, write a function exp(n, pow) of type: (int, int) -> int where pow >= 0, so that the result is n**pow. For example, assert exp(5,0) == 1 assert exp(2,3) == 2*2*2 assert exp(2,2) == 4 assert exp(2,1) == 2 assert exp(5,3) == 5*5*5 assert exp(10,4) == 10*10*10*10 assert exp(9,5) == 9*9*9*9*9 assert (-3,3) == -3 * -3 * -3 ------------------------------------------