CSC 15 Lab 4: Functions, Loops, and Arrays Due in one week. This class will ask you to write series of functions using loops and arrays. The first part is to be done directly in interactive Python. The second part should be written as a separate program. Only the second part should be submitted. PART I: Preliminary Drills on Loops and Arrays: The following problems should be completed inside the Python interactive interpreter (it will not be collected, and are only provided for your benefit). a. Write a while loop that prints every even number from 0 to 100, inclusive. I.E. the first value should be 0, then 2, then 4, etc... and the last number should be 100. Think carefully about how the loop should start and when it should end. b. Write a while loop that prints every odd number between 0 and 100 BACKWARDS, i.e., 99, 97 ... c. Write a while loop that constructs an array of all odd numbers between 0 and 100 backwards. Hint: start with an empty array A = [] then use A.append(...) in your loop. d. Write a function that take as a parameter n, and returns an array of all odd numbers from 1 to n. If n is 0 or negative, then the function should return [] That, is complete the following: def oddsUpTo(n): ... So that, for example, calling print oddsUpTo(8) will print [1,3,5,7] (i.e., the function should return [1,3,5,7]) The following is an example of a function that returns an array (of binary factors of n) def binfactors(n): F = [] # array to be returned power = 0 while n>0: if (n%2==1): F.append(2**power) n = n/2 power += 1 return F #binfactors print binfactors(147) # prints [1, 2, 16, 128] e. Write a function that takes an array as a parameter and returns the number of positive numbers in the array. That is, complete the definition of: def positives(A): ... so that, for example, calling positives([-2,-5,1,0,7,-6]) will return 2, because there are two positive numbers in this sample array. REMEMBER that you functions must work for any input array, and do not use input/print statements inside the function. Only print outside the function. ----------------------------------------- PART II: Write the following functions in Python. Everything should be in the same file. 0. Write a function that reverses an array. For example, reverse([2,4,5,7]) should return an array [7,5,4,2]. Hint: do not try to change the existing array. Contruct a new array starting from []. 1. Write a function largesti that returns the INDEX of the largest element in an array (which is passed in as a parameter). If there are multiple occurrences of the largest element, the function should return -1. For example, largesti([2,4,1,7,3]) should return 3, since the largest element, 7, is at position 3. largest([4,1,6,2,6]) should return -1 because there's a tie. Devise several function calls to make sure the code is working correctly. e.g. largesti([2,4,1,7,3]) Example: the following function returns the index of x in A, or -1 if x is not in A: def indexof(x,A): answer = -1; // -1 means x not found in A i = 0 # indexes A while answer==-1 and i