# CSC 15 Basic Practice Problems # Test your solutions in Python (make sure you can call the functions too). #0a Write code to construct a list containing all the numbers that are # evenly divisible by 8 from 0 to 10000, i.e., the list # [0,8,16,24,32,40,48,56,64, ... 10000]. Hint: first line is M = [] x = 0 # numbers to be added to list while x<=10000: M.append(x) x = x+8 # end while # another solution, this time the "iterator" i is incremented by one each time: M=[] i = 0 while i<=10000: if (i%8==0) M.append(i) i=i+1 #end while #0b. Write a function 'product' that multiplies all numbers in an array. # For example, product([3,2,5]) should return 30. Hint: the product # of the empty array is 1 def product(A): i = 0 # loop counter, indexes A prod = 1 # running product while i=0 R.append( A[i] ) i =i-1 return R #3a. Write a function h that returns True iff there is a number greater than 100 # in a list. For example, h([4,6,1,109,3]) should return True. It should # return False otherwise. def h(A): answer = False # default for "there exists" type of problems i = 0 while i100: answer = True i = i+1 return answer #3b Write a function h2 that returns True iff there is at least 2 numbers # in the given list that's greater than 100. For example, h2([4,6,1,109,3]) # should return False, and h2([45,180,21,346,12]) should return True def h2(A): count = 0 # counts numbers seen that are > 100: i = 0 while i100: count = count+1 i = i+1 if count>=2: return True else: return False # can also just say return (count>=2); #4 Write a nested loop that prints # # X X X X X # X X X X # X X X # X X # X # # The outer loop should run 5 times. The inner loop prints each line. i = 5 # outer loop counter while i>=1: j = 0 # inner loop counter while j