Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1tests = [(5, 25), (0, 0)] | A(4, 16) | |
| 2tests.append((3, 9)) | BThe second tuple is closed with a square bracket ] instead of a round bracket ), so the code has a syntax error. | |
| 3Each test case is one tuple that pairs an input with its expected output | CAdds a new test case with input 3 and expected output 9 to the end of the list | |
| 4A loop can unpack each tuple in the list so every test case is run in turn | D(0) is not a tuple and only holds the input, so the expected output is missing and this test case is incomplete. | |
| 5tests = [(5, 25), (0, 0] | ECreates a list holding two test cases, each stored as an (input, expected) tuple | |
| 6tests = [(5, 25), (0)] | Ffor x, expected in tests: |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
tests = [(5, 25), (0, 0)] — A list of (input, expected) tuples. Each tuple is one test case, so a loop can run many tests stored in one variable. Add a new tuple to add a new test.tests = [(5, 25), (0, 0)]# expected is the square of the input
tests = [(3, 9), (0, 0)]tests = [(5, 25), (0, 0)]
tests.append((4, 16))tests = [(2, 4), (3, 9)]
for inp, expected in tests:
print(inp, expected)tests = [(5, 25), (0, 0)]
# expected output of the first test case
print(tests[0][1])