Problem 1: 27/15, int, 1 32%11, int, 10 sum(range(6)), int, 15 len("dog") < len("catsup"), boolean, true "1,234,567".split(",") list, ["1", "234", "567"] "platform"[-2], string, "r" "beat"+"nick", string, "beatnick" "snapdragon"[3:8] string, "pdrag" 0.23*10, float 2.3 [8,7,6,7,6,5,4,3,2,1][5:7] list [5,4] 2**4 int 16 Part B: def rorhrer(weight,height): return 1.0*wieght*2768/(height**3) def triangle_area(a,b,c): s = (a+b+c)/2.0 area = math.sqrt(s*(s-a)*(s-b)*(s-c)) return area def divisor_sum(n): return sum([k for k in range(1,n) if n % k == 0]) or s = 0 for k in range(n): if n % k == 0: s = s + k return s def is_amicable(x,y): return divisor_sum(x) == y and divisor_sum(y) == x def nearby(city,clist,apart): ret = [] for elt in clist: if distance(elt[1],elt[2],city[1],city[2]) <= apart: ret.append(elt[0]) return ret ******* Problem 3 Part A The one test that doesn't pass is the third, when "big" is b then the expression b in ["bad","news", "is", "trouble"] evaluates to true so "clean" is returned, the word "bad" is never checked. Move the else: outside the loop, e.g., def censored(bad,headline): words = headline.split() for b in bad: if b in bad: return "censored" return "clean" ****** Part C: index+2 skips the comma and space to get the first name the slice uses index to get everything up to and NOT including the comma Part D: .find() returns -1 when the string isn't found, so -1+2 = 1 and the slice gets "ob jones". The value of the slice "bob jones"[:-1] is everything upto and not include the last character or "bob jone" ****** Problem 4 'dog', no ie and no ei found line 8 since eii isn't 0 and 'c' occurs before the 'ei' line 6 for similar reasons Part B: control falls through to the end since all the if expressions are false so False is returned as no other return statements execute Part C: Start code with: if iei == 0: return False if eii == 0: return True