# Wolverine Rumble question file # # A plain-text file holding any number of questions. Lines that start with # (not indented) are # comments; they are skipped. Everything below the notes is a real six-question file you can copy. # # Each question starts with a header line: its type in square brackets, then fields separated by |. # [mc] tags: Unit 3 Python, operators | time: 30 | points: 1000 # Types: mc = multiple choice, tf = true/false, fill = fill in the code, error = find the error, # order = put the lines in order, code = code challenge. # tags: is required (one or more, separated by commas). time: is in seconds and points: is a number; # leave them out to use the defaults from Settings. submissions: is for code challenges only. # A tag your bank doesn't have yet is listed before you import. A tag within a letter or two of one # you already have is flagged as a likely misspelling. # # Right after the header comes the question text, on one or more lines. # Code is indented by two spaces (or a tab). It keeps its own indentation; the shared indent is removed. # Multiple choice: one line per choice, starting with * for the right one and - for the others. # True/false: one line, * true or * false. # Fill in the code: write ___ (three underscores) where the student types, then one line per blank: # blank 1: range | xrange (accepted answers, separated by |) # Find the error: error: line 2 (counting the code lines from 1). # Put the lines in order: just the code, in the right order. Students see it scrambled. # Code challenge: shape: program (reads input, prints) or shape: function NAME; optional starter code, # indented; then the tests. A test is test:, test shown: or test hidden:, with input: and output: # (or call: and returns: for a function) indented under it. A value that needs several lines goes on # its own lines, indented two more spaces. The first test is shown unless you say otherwise. # Every question ends with why: the one line students see with the right answer. # Week 8 questions [mc] tags: Unit 3 Python, operators | time: 30 | points: 1000 What does this print? x = 7 % 3 print(x) * 1 - 7 - 3 - 2 why: % gives the remainder of 7 divided by 3. [tf] tags: Unit 3 Python, operators 5 // 2 == 2.5 * false why: // drops the decimal part, so 5 // 2 is 2. [fill] tags: Unit 3 Python, loops | time: 60 Complete the loop so it prints 0 to 4. for i in ___(5): print(i) blank 1: range why: range(5) gives 0, 1, 2, 3, 4. [error] tags: Unit 3 Python, loops Which line has the bug? total = 0 for n in nums total += n print(total) error: line 2 why: A for line ends with a colon. [order] tags: Unit 3 Python, loops Put the lines in order so the program prints the sum. total = 0 for n in [3, 5, 7]: total = total + n print(total) why: Set the total first, add inside the loop, print after. [code] tags: Unit 3 Python, functions | time: 300 | points: 1000 | submissions: 3 Write a program that reads a whole number and prints its square. shape: program n = int(input()) # print the square of n test shown: input: 4 output: 16 test hidden: input: -3 output: 9 test: input: 12 output: 144 why: Multiply the number by itself, or use n ** 2.