← QCE Digital Solutions Unit 4

Testing a prototype for accuracy

Comparing the prototype's actual output with expected results worked out by hand from known data, to find wrong values such as rounding or conversion errors.

Understanding Testing a prototype for accuracy in QCE Digital Solutions Unit 4

What it does: The hand-calculated expected result is stored first, then compared with the actual output from the prototype. int() cuts off the decimal part, giving 2, but round(2.5, 1) keeps 2.5. Comparing against the hand-calculated 2.5 reveals the error. By hand: 3 x 2.50 = 7.50. GST is 0.75. Total is 8.25. Accuracy testing looks for changes between what was received and what is displayed, such as a truncated or wrongly converted number. Layout is a usability matter. Accuracy is about whether values are correct, not whether the code runs. Wrong rounding or conversions give no error message.

Common mistakes: The conversion formula is upside down. By hand, 25 * 9 / 5 + 32 = 77.0, but 5 / 9 gives about 45. The test would fail because of a formula error, so the line should be celsius * 9 / 5 + 32. int() truncates 19.999 to 19 instead of rounding it. The hand-calculated expected value is 20.0, so the prototype must round with round(price, 1).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 334–401) and word search (Modules 127–401).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which is the correct way to get the expected result in an accuracy test?
Work it out by hand from known input data before running the prototypeCopy whatever the prototype outputs and call it expected
Matches
expected = average([70, 80, 90]) assert average([70, 80, 90]) == expected
↓
The expected value is produced by the program itself, not worked out by hand, so the test always passes and proves nothing.
Applying
Meanings
Term
accuracy testing
Meaning
Comparing the prototype's actual output with expected results worked out by hand from known data, to find wrong values such as rounding or conversion errors.
Practice
def to_fahrenheit(c):
Testing
Gaps
print(actual expected)
Check Answer
Spots
2expected = 77.0
3actual = celsius * 5 / 9 + 32

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Ostrich' badge — Full Sprint, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which is the correct way to get the expected result in an accuracy test?
A. Work it out by hand from known input data before running the prototype ✓
B. Copy whatever the prototype outputs and call it expected
Expected results must come from an independent source, such as a hand calculation. If you copy the prototype's output, the test can never fail.
2. A weather API sends 22.0 degrees Celsius. Your prototype should display Fahrenheit. Which expected value is worked out by hand correctly?
A. 54.0 (22 x 9 / 5 - 32 + 32 - 22 + 54)
B. 71.6 (22 x 9 / 5 + 32) ✓
By hand: 22 x 9 / 5 = 39.6, then + 32 = 71.6. The expected value is calculated from the known input before checking the output.
3. The prototype receives a price of 4.995 and displays 5.00 when the spec says to round to 2 decimal places. What does the test show?
A. It matches only if the hand-calculated expected value is 5.00 under the stated rounding rule ✓
B. It always fails because the numbers are different
Rounding errors depend on the rule used. Decide the rounding rule first, calculate the expected value by hand, then compare.
4. Test data: 3 items at $2.50 each with 10% GST added. Which expected total should you record?
A. $7.75
B. $8.25 ✓
By hand: 3 x 2.50 = 7.50. GST is 0.75. Total is 8.25.
5. Which check compares received vs displayed data?
A. Compare the value in the API response with the value shown on screen ✓
B. Check that the screen layout looks neat
Accuracy testing looks for changes between what was received and what is displayed, such as a truncated or wrongly converted number. Layout is a usability matter.

Match the Pairs

assert round(c * 9 / 5 + 32, 1) == 98.6 → Checks the converted temperature matches the answer worked out by hand for a known input of 37 degrees Celsius
print(received == displayed) → Compares the data received from the API with the data shown on screen to see if it changed on the way
Work out the expected value by hand first (3 items at 4.50 = 13.50), then compare it with the program's total → expected = 13.50 actual = total_cost(3, 4.50) print(actual == expected)
A rounding error appears when the output differs from the expected value, for example 2.5 shown as 2 → print(int(2.5), round(2.5, 1))
expected = average([70, 80, 90]) assert average([70, 80, 90]) == expected → The expected value is produced by the program itself, not worked out by hand, so the test always passes and proves nothing.
assert price_with_gst(100) == 10.0 → The expected result was worked out wrongly. 100 plus 10% GST should be 110.0, so the test checks against the wrong value.

Key Term

accuracy testing
Comparing the prototype's actual output with expected results worked out by hand from known data, to find wrong values such as rounding or conversion errors.

Fill in the Blanks

1. expected = 59.97 actual = round(19.99 * 3, 2) print(actual == expected)
Hint: Type the comparison operator that checks whether the actual output equals the hand-calculated expected value.
2. total = 10 / 3 shown = round(total, 2) print(shown)
Hint: Type the built-in function that rounds a number to a set number of decimal places, so the output can be checked against 3.33 worked out by hand.
3. expected = 212 actual = 100 * 9 / 5 + 32 print(actual == expected)
Hint: Type the arithmetic operator that multiplies the Celsius value in the conversion formula. The hand-calculated result for 100 C is 212 F.
4. received = 42.5 displayed = float("42.5") print("Mismatch:", received != displayed)
Hint: Type the comparison operator that is True when the received value and the displayed value are different.
5. expected = 59.97 actual = 19.99 * 3 print(abs(actual - expected) < 0.01)
Hint: Type the built-in function that gives the size of the difference between actual and expected, ignoring whether it is positive or negative.

Spot the Error

Question 1
A celsius = 25
B expected = 77.0
C actual = celsius * 5 / 9 + 32
D print(actual == expected)
Line C — The conversion formula is upside down. By hand, 25 * 9 / 5 + 32 = 77.0, but 5 / 9 gives about 45. The test would fail because of a formula error, so the line should be celsius * 9 / 5 + 32.
Question 2
A price = 19.999
B expected = 20.0
C shown = int(price)
D print(shown == expected)
Line C — int() truncates 19.999 to 19 instead of rounding it. The hand-calculated expected value is 20.0, so the prototype must round with round(price, 1).
Question 3
A marks = [80, 70, 90]
B expected = 240
C avg = sum(marks) / len(marks)
D print(avg == expected)
Line B — The hand calculation is wrong. The total is 240, but the average needs 240 / 3 = 80. An incorrect expected value makes the accuracy test meaningless.
Question 4
A received = {'temp': 21.5}
B shown = received['temp']
C assert shown == 215
Line C — The received data says 21.5, so the displayed value must be compared with 21.5. Writing 215 drops the decimal point and would wrongly report a display error.
Question 5
A km = 12.5
B miles = km * 0.621371
C want = 7.77
D print(round(miles, 1) == want)
Line D — By hand, 12.5 * 0.621371 = 7.7671, which is 7.77 to 2 decimal places. Rounding to 1 place gives 7.8, so the comparison fails. It should be round(miles, 2).

Student with a class code? Join your class →