Recording actual results and a pass or fail verdict

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Recording actual results and a pass or fail verdict

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Your program printed 'Total: 45' but you wrote the actual result as '45'. Is this the right way to record it?
A Yes. Shortening the output is fine as long as the number is the same
B No. Copy the actual result exactly: Total: 45
2. Expected result: 12. Actual result: 12. What verdict do you record?
A Fail
B Pass
3. Expected result: 7.5. Actual result: 7. What verdict do you record?
A Fail
B Pass
4. A test fails because the program output 20 but you expected 25. What should you do with the expected result?
A Leave it as 25 and record the Fail
B Change it to 20 so the test passes
5. Which entry in the Notes column is better for a failed test?
A Output was 20 but 25 expected. Total may be missing the last item
B Failed

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Expected: 15 | Actual: 15 | Result: Pass AThe result is marked Pass even though the actual result (10) does not match the expected result (20). It should be Fail.
2Expected: 15 | Actual: 5 | Result: Fail BExpected: 20 | Actual: 10 | Result: Fail | Note: added instead of multiplied
3Copy the actual result exactly as the program displayed it, including spaces, capitals and punctuation. CThe expected result was changed to match the actual result, which hides the bug. The expected result must stay 20 and the test should be marked Fail.
4When a test fails, keep the expected result unchanged and write a note describing what went wrong. DThe actual result matches the expected result exactly, so the test is marked Pass.
5Expected: 20 | Actual: 10 | Result: Pass EThe actual result does not match the expected result, so the test is marked Fail and a note should be added.
6Expected: 10 (changed from 20) | Actual: 10 | Result: Pass FActual: Total: $12.50

Definitions

Pass or Fail

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
expected = 5 actual = add(2, 3) if actual __ expected: print("Pass")
2.
v = "Pass" if actual == expected ____ "Fail"
3.
if actual != expected: print("Fail: got", actual, "want", ________)
4.
actual = add(2, 3) print("Actual:", ______)
5.
expected = 5 actual = add(2, 2) if actual != ________: print("Fail")

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A expected = actual
B actual = 4 * 5
C if actual == expected:
D print("PASS")
E else:
F print("FAIL")
Question 2
A expected = 20
B actual = 4 * 4
C if actual = expected:
D print("PASS")
E else:
F print("FAIL")
Question 3
A expected = 7.5
B actual = 15 / 2
C if actual != expected:
D print("PASS")
E else:
F print("FAIL")
Question 4
A expected = 30
B actual = 5 * 5
C expected = actual
D print(actual == expected)
Question 5
A expected = 12
B actual = 3 + 4
C if actual == expected:
D print("FAIL")
E else:
F print("FAIL")

Answer Key

Recording actual results and a pass or fail verdict
Section A: Quick Questions
Q1
B — No. Copy the actual result exactly: Total: 45
Q2
B — Pass
Q3
A — Fail
Q4
A — Leave it as 25 and record the Fail
Q5
A — Output was 20 but 25 expected. Total may be missing the last item
Section B: Match the Pairs
Q1
Expected: 15 | Actual: 15 | Result: Pass → The actual result matches the expected result exactly, so the test is marked Pass.
Q2
Expected: 15 | Actual: 5 | Result: Fail → The actual result does not match the expected result, so the test is marked Fail and a note should be added.
Q3
Copy the actual result exactly as the program displayed it, including spaces, capitals and punctuation. → Actual: Total: $12.50
Q4
When a test fails, keep the expected result unchanged and write a note describing what went wrong. → Expected: 20 | Actual: 10 | Result: Fail | Note: added instead of multiplied
Q5
Expected: 20 | Actual: 10 | Result: Pass → The result is marked Pass even though the actual result (10) does not match the expected result (20). It should be Fail.
Q6
Expected: 10 (changed from 20) | Actual: 10 | Result: Pass → The expected result was changed to match the actual result, which hides the bug. The expected result must stay 20 and the test should be marked Fail.
Section C: Definitions
Q1
Pass or Fail — Copy the actual result exactly as the program gave it, then mark Pass only if it matches the expected result, otherwise Fail. Never change the expected result to fit, and add a note for fails.
Section D: Fill in the Blanks
Q1
expected = 5 actual = add(2, 3) if actual == expected: print("Pass")
Q2
v = "Pass" if actual == expected else "Fail"
Q3
if actual != expected: print("Fail: got", actual, "want", expected)
Q4
actual = add(2, 3) print("Actual:", actual)
Q5
expected = 5 actual = add(2, 2) if actual != expected: print("Fail")
Section E: Spot the Error
Q1
A — The expected result must be worked out before the test and kept fixed. Copying the actual result into expected makes the test pass automatically (and actual does not exist yet). It should be expected = 20.
Q2
C — A single = assigns a value, so it cannot compare the actual and expected results. Use == to check for a match: if actual == expected:
Q3
C — Pass means the actual result matches the expected result. With != the test would print PASS when the results are different. It should be if actual == expected:
Q4
C — The program must not change the expected result to fit what it produced. Doing that hides the failure (25 is not 30). This line should record the actual result: print("Actual:", actual)
Q5
D — This branch runs when actual matches expected, so the verdict must be Pass. It should be print("PASS"). The FAIL message belongs in the else branch.