Problem 1 A1. [3, 5, 5, 7, 4] A2. 7 A3. ['chicken'] A4. 'chicken' B1. 'rhino' B2. Mystery returns the longest string. If there are multiple strings of that length, it returns the first such. B3. amount = max([len(w) for w in animals]) B4. Mystery still returns the longest string. If there are multiple strings of that length, now it returns the last such. Problem 2 def whoseNightToCook(day, month): if day %2 == 0: # even day return "Ellen" if day == 31 and month % 2 == 0: return "Ellen" return "Oscar" # ALTERNATE SOLUTION: def whoseNightToCook(day, month): if day%2 == 0 or (day == 31 and month %2 == 0): return "Ellen" else return "Oscar" Problem 3 lists of size 2 cause denominator to be zero in both cases, division b zero doesn't make sense mathematically, and for int values causes an error (for float too). the list is sorted so that low and high values occur first and last, respectively, and slicing removes them def computeScore(scores): low = min(scores) high = max(scores) lowc = scores.count(low) highc = scores.count(high) return (sum(scores)-low*lowc-high*highc) / (len(scores)-lowc-highc) # ALTERNATE SOLUTION: def computeScore(scores): low = min(scores) high = max(scores) nlist = [ s for s in scores if s != low and s != high ] return sum(nlist) / len(nlist) Problem 4 def getScore(filename,uname): file = open(filename) score = 0 lineNum = 0 for line in file: lineNum += 1 parts = line.split(",") if parts[1] == uname: score += lineNum file.close() if score == 0: return "NO SCORE" return score # ALTERNATE SOLUTION: def getScore(filename,uname): file = open(filename) score = 0 for i,line in enumerate(file): parts = line.split(",") if parts[1] == uname: score += (i+1) # ALTERNATE SOLUTION: def getScore(filename,uname): file = open(filename) score = 0 nlist = file.readlines() for line in nlist: parts = line.split(",") if parts[1] == uname: score += nlist.index(line)+1 -- to score just top five, add scoreCount = 0 before loop, increment scoreCount += 1 in if statement and change if statement to guard: if parts[1] == uname and scoreCount < 5: