# loop to construct array of 50 fibonacci numbers a = 1 b = 1 n = 0 # controls length of array to be built: FIB = [1] # array to be built, starting with 1 while n<50: FIB.append(b) (a,b) = (b,a+b) n += 1 # print FIB print len(FIB) # 51 why? #### alternative: FIB = 50*[0] # notation means create array of 50 zeros FIB[0] = 1 FIB[1] = 1 i = 2 # next fib index while i A[i]: # why not axi > i? axi = i i = i+1 # while return axi # smallesti # return index of smallest element, -1 if there's a tie for smallest: def winneri(A): axi = 0 tie = False i = 1 while i A[i]: # why not axi > i? axi = i tie = False else: #### what's wrong if there's no else here? if A[axi] == A[i]: tie = True # if-else i = i+1 # while if (tie): return -1 else: return axi # winneri print winneri([4,5,2,7,9,1,4]) print winneri([6,3,2,4,5,2,10]) ### Boolean functions: functions that return True or False # function to determine if all numbers in a list are positive: def positive(A): # predicate true if all elements of A are positive answer = True i = 0 while i