Multiple Choice 1. e 2. a 3. e 4. b 5. a 6. a 7. a 8. a 9. b 10. a 11. c 12. b 13. c 14. a 15. b 16. e 17. a 18. b 19. d 20. a 21. e 22. e 23. c 24. b 25. a 26. a 27. a 28. b 29. b 30. c 31. b 32. e 33. cd Problem 3b Any word with length 1 with return doubled. Examples: word = 'a' letter = 'a' actual return value = 'aa' correct return value = 'a' Problem 3c def removeInnerLettersCorrect(word, letter): # Add these two lines, the check can also be < 2 or == 1 if len(word) <= 2: return word newWord = word[0] for c in word[1:-1]: if c != letter: newWord += c return newWord + word[-1] Problem 4a def force(mass1, mass2, distance): # Extra parenthesis are allowed return 6.674 * 10**-11 * mass1*mass2/distance**2 Problem 4b def futureValue(principle, interest, num, time): # Extra parenthesis are allowed return principle*(1 + interest/num) ** (num * time) Problem 5 def countDivisors(n): c = 0 for i in range(1,n+1): if n % i == 0: c += 1 return c Problem 6 def zipper(lst1, lst2, merge): ret = [] for i in range(len(lst1)): ret.append(merge(lst1[i], lst2[i])) return ret Problem 7 # There were many ways to implement this, see bottomm for tests to check implementation def crazyHopping(lst): i = 0 hops = 0 while i < len(lst) and hops < len(lst): i = lst[i] hops += 1 if i < len(lst) and hops >= len(lst): return -1 else: return hops def crazyHopping(lst): i = 0 hops = 0 while i <= len(lst)-1 and hops <= len(lst): i = lst[i] hops += 1 if hops > len(lst): return -1 else: return hops def crazyHopping(lst): i = 0 hops = 0 while (hops <= len(lst)): # < or <= does not matter i = lst[i] hops += 1 if i >= len(lst): return hops return -1 def crazyHopping(lst): hops = 0 i = 0 while i < len(lst): i = lst[i] hops += 1 if hops > len(lst): return -1 return hops def crazyHopping(lst): hops = 0 curr = lst[0] for i in range(len(lst)): if curr >= len(lst): return hops + 1 curr=lst[curr] hops+=1 return -1 crazyHopping([1,0]) == -1 crazyHopping([2, 3, 1]) == 3 crazyHopping([4,0,0,4,3]) == -1 crazyHopping([4]) == 1 crazyHopping([2,5,5,5]) == 2 crazyHopping([0]) == -1 crazyHopping([1,2,3,4]) == 4 crazyHopping([1]) == 1