# Quiz #1 Solutions # September 11, 2012 # The code blocks were worth 2 points apiece. # 1a Since 7 divides into 17 twice with a remainder of 3, # we have 17/7 = 2 and 17%7 = 3, so the output will be # 5 is just fine # 1b Since 18 is not equal to 10 the first if statement will # execute, so we skip over the elif and else statements, giving # Roses are red # 1c Note that 2**3 means (2)(2)(2), or 8. Similarly 3**2 = 9. # Therefore the output will be # Is two cubed equal to 8 or 9 ? # 1d The quantity `lucky' will be a number in the 20s regardless # of what digit is equal to, making lucky/10 equal to 2. The answer is # Tim buck 2 # 1e Both if statements are true, so both statements print, giving # Believe it or not. # 2 (3 points) The corrected code appears below. Note the quotes with the # input statement, the double equal sign, the second appearance of `value' # and the indented print statement. value = input("Enter a two-digit number: ") if value%2 == 1 and value < 77: print "That's a nice number!" # 3 (7 points) One program appears below. Variations are possible, as usual. num = input("Enter a three-digit number: ") if num >= 600 and num <= 699: print "Your number rocks." else: print "Sassafras." weeks = num/7 print "There are", weeks, "full weeks in", num, "days."