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 | |
|---|---|---|
| 1for value, expected in tests: | AA single = was used in the if condition. It assigns a value instead of comparing, which causes a SyntaxError. It should be ==. | |
| 2actual = double(value) | BThe loop only has one variable, so the whole (input, expected) tuple goes into value and expected is never defined. It should be for value, expected in tests. | |
| 3Print PASS when the actual result matches the expected result | Cif actual == expected: print("PASS") | |
| 4On a failure, print both values so you can see what went wrong | DLoops through the list of test tuples and unpacks each one into an input value and an expected result | |
| 5for value, expected in tests: actual = double(value) if actual = expected: print("PASS") | ECalls the function with the test input and stores the real result to compare with the expected result | |
| 6for value in tests: actual = double(value) if actual == expected: print("PASS") | Felse: print("FAIL", expected, actual) |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
for value, expected in tests: — Loops over each (input, expected) tuple in tests, unpacking it into two variables. Then you call the function, compare actual to expected, and print PASS, or FAIL with both values.for value, expected in tests:
actual = double(value)for value, expected in tests:
actual = double(value)for value, expected in tests:
actual = double(value)for value, expected in tests:
actual = double(value)
if actual == expected: print("PASS")
else:
print("FAIL", actual, expected)