1. a) (10 != 200) and (True) True b) (not (13 < 15)) or (13 > 10) True c) not(not(13 != 13)) False d) (10 < 20) and ((20 < 30) or (20 != 20)) True e) (13 == 10) or ((13 < 10) or (not (13 > 20))) True f) abs(5 - 25) < 15 False g) (int(len("hello")/3.0) == 1) and (not(len("hi") >= 2)) False h) not(not(not False)) or (False or True) True i) (5 < 10) and ((10 < 5) or ((3 < 18) and not (8 < 18))) False j) (not (5 < 10)) or (not (3 != 4) and not (8 > 11)) False 2. a) math.ceil(5.75) - math.floor(5.75) 1.0 b) math.ceil(5) - math.floor(5.0) 0.0 c) math.trunc(10.5)/3 3 d) math.pow(2, 3) - math.pow(3, 2) -1.0 e) math.factorial(5)/10 12 f) math.ceil(math.sqrt(20)) 5.0 g) math.floor(math.log10(50)) 1.0 3. a) (sys.maxint + 2) - 5 2147483644L b) sys.maxint + (2 - 5) 2147483644 c) 0L + 1 1L d) 89.0 + 10L 99.0 e) 89 + int(10L/10) 90 f) long(89) + int(10L/10) 90L 4) while True: inputString = raw_input("Enter a positive integer: ") if(inputString == "done") : break n = int(inputString) factor = 1 outputString = "Factors: " while factor <= n: if n % factor == 0: outputString = outputString +" "+ str(factor); factor = factor + 1 print outputString 5) import sys # Variable used to read input numbers current = int(raw_input("Type a positive int (zero if done).")) # tracks the number just prior to the most recently read number previous = sys.maxint # counter to track the number of consecutive, increasing pairs numIncreasingPairs = 0 while current != 0: if current > previous: numIncreasingPairs = numIncreasingPairs + 1 previous = current current = int(raw_input("Type a positive int (zero if done).")) print numIncreasingPairs