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 | |
|---|---|---|
| 1assert add(2, 3) == 5 | AUses = (assignment) instead of == (comparison), which causes a SyntaxError | |
| 2for x, want in tests: assert double(x) == want | BRuns the same assert check on every test case in a list | |
| 3A boundary test checks a value at the edge of the allowed range, such as 0 or 100 | CThe expected value is wrong, because add(2, 3) is 5, so the test fails with an AssertionError | |
| 4An invalid input test checks the function handles a bad value like a negative number | Dassert is_pass(50) == True | |
| 5assert add(2, 3) = 5 | EChecks that add(2, 3) gives 5 and raises an AssertionError if it does not | |
| 6assert add(2, 3) == 6 | Fassert grade(-5) == "Invalid" |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
assert — Checks a condition is True, like assert add(2, 3) == 5. If the result is not what you expected, it raises an AssertionError, so test cases can run automatically.assert add(2, 3) == 5assert add(2, 3) == 5cases = [(1, 2, 3), (0, 0, 0)]
for a, b, expected in cases:
assert add(a, b) == expectedassert positive(0) == Falsetests = [(2, 3, 5), (0, 0, 0)]
for a, b, expected in tests:
assert add(a, b) == expected