HelpContactFor teachers and institutes
>_StemPy Lab
Mock TestsClasses

>_StemPy Lab

Learn. Solve. Code the solutions. Test yourself.

Live examsFree mock exams, timed and rankedEveryone starts together, and your score and rank come the moment it ends.See the exams →

Learn

  • Physics
  • Chemistry
  • Mathematics
  • Biology
  • Python Programming
  • Statistics & Data Science
  • Computer Science
  • Classes
  • Groups

Practice

  • Problems
  • Quizzes
  • Mock Tests
  • Prepare for an Exam
  • Question Sets
  • Exams
  • Certificates
  • Python Labs
  • AI Practice Generator
  • Student-Created Tests

Community

  • Discussions
  • Resources
  • Notes
  • Glossary
  • Blog

Account

  • Log in
© 2026 senLearn. All rights reserved.HelpFor SchoolsAboutContactPrivacy PolicyTerms of UseRefund Policy
Pseudocode, Trace Tables and Testing
  1. 1Writing pseudocode
  2. 2Trace tables and dry runs
  3. 3Test data and finding errors
  1. Computer Science
  2. /Pseudocode, Trace Tables and Testing
  3. /Test data and finding errors

Course 7.2·Lesson 3 of 3

Test data and finding errors

A program is tested with data chosen on purpose. You learn the four kinds of test data in the syllabus: normal, abnormal, extreme and boundary. Then you use dry runs and test data to find errors in algorithms and to suggest how to correct them.

about 25 min1 simulation1 practice question
Lesson 3 of 3Show all lessonsHide
Pseudocode, Trace Tables and Testing
  1. 1Writing pseudocode
  2. 2Trace tables and dry runs
  3. 3Test data and finding errors

Try the code and the simulations beside the lesson.

Testing on purpose

When you check a calculator, you do not only try 2+22 + 22+2. You also try a very large number, a negative number and a division by zero. The aim is to find out where it goes wrong. Testing a program is the same. You choose test data, write down the result you expect, run the program and compare.

The four kinds of test data

Take a program that accepts the number of tickets in an order: whole numbers from 111 to 505050.

A number line, not to scale, with the range 1 to 50 shaded as accepted. The values 1 and 50 are labelled extreme (and boundary). The values 0 and 51, just outside, are labelled boundary, rejected. The value 25 is labelled normal. A note says abnormal: -7, 64, "ten".
  • Normal data is data that should be accepted and is well inside the range, such as 252525.
  • Abnormal data is data that should be rejected, such as −7-7−7, 646464 or the text "ten".
  • Extreme data is the largest or smallest value that is accepted: 111 and 505050.
  • Boundary data is the largest or smallest accepted value and the value next to it that is rejected: 111 and 000 at the bottom, 505050 and 515151 at the top.

Extreme data tests the very edge of what is allowed. Boundary data tests both sides of the edge. Many errors sit exactly at a boundary, for example > written where >= was needed.

A test is written as a row of a test plan: the kind of data, the value, and the expected result.

  • normal, 252525, accepted;
  • extreme, 505050, accepted;
  • boundary, 515151, rejected;
  • abnormal, "ten", rejected.

Finding errors in an algorithm

The syllabus asks you to find the errors in a given algorithm and to suggest a correction. Dry-run it with simple test data, and compare the result with what it should be. This algorithm should input five numbers and output their total.

pseudocode
Total ← 0
FOR Count ← 1 TO 5
    INPUT Number
    Total ← Number
NEXT Count
OUTPUT Total

Try the inputs 333, 888, 222, 666 and 444. The total should be 232323, but the algorithm outputs 444. A trace table shows why: Total takes the value of each number in turn, so only the last one is left. The line Total ← Number should be Total ← Total + Number.

Errors you will often meet in exam algorithms:

  • a wrong starting value, such as Highest ← 100 before looking for a highest value;
  • a wrong operator, such as < instead of >, or > instead of >=;
  • a loop that runs the wrong number of times, such as 1 TO 4 for five inputs;
  • a statement in the wrong place, such as an output inside a loop that should come after it;
  • a missing statement, such as no INPUT inside a loop.

When you suggest a correction, write the whole corrected line in pseudocode, not just a description.

Practise with new numbers

Try it in Python

This Python program runs a whole test plan. Each test gives the kind of data, the input and the expected result. The program prints pass when the result matches. You met isinstance and lists of pairs in the Python Essentials book.

Read it first. Then run it. Does every test pass?

1. Change the check to 1 <= quantity < 50. Which test now fails? What kind of data found the error?

2. Add a test for the abnormal value 3.5. What should the expected result be?

Common mistakes

  • Calling 515151 extreme data. Extreme data is accepted. 515151 is rejected, so it belongs to the boundary pair.
  • Testing only normal data. Most errors show at the edges, so always test both boundaries.
  • No expected result. A test is useless unless you say first what should happen.
  • Describing a fix vaguely. Write the corrected line, such as IF Mark > Highest.

Remember these

  • Normal: accepted, inside the range. Abnormal: should be rejected.
  • Extreme: the largest or smallest accepted value.
  • Boundary: the largest or smallest accepted value and the next value that is rejected.
  • Find errors by dry-running with simple data, then write the corrected line.

Check yourself

Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.

  1. A form accepts an age from 111111 to 181818. Give the two extreme values.
  1. For the same form, give the boundary data at the lower end.
  1. Is the input "twelve" normal, abnormal, extreme or boundary data for the age form?
  1. An algorithm should output the largest of some marks. It starts with Largest ← 100. What goes wrong, and what is a correction?
  1. A check meant to accept 111 to 505050 is written IF Quantity > 1 AND Quantity <= 50. Which test value shows the error?

References

  • Cambridge International, IGCSE Computer Science 0478 syllabus (2026, 2027 and 2028), unit 7, parts 6 and 8: test data and errors in algorithms.

Enroll free in Pseudocode, Trace Tables and Testing

Every lesson is open to read. Enrolling also lets you:

  • Mark lessons done and carry on where you stopped.
  • Count the course towards the certificate for its chapter.
No payment. You can leave at any time.

Problems (3)

A program asks for the number of a month, a whole number from 1 to 12…Easy · High School (9–10) · by StemPy Lab
This algorithm should input five marks, each from 0 to 100, and output the highest mark…Hard · High School (9–10) · by StemPy Lab
A swimming pool gives a teen ticket to anyone aged from 13 to 19, both included…Medium · High School (9–10) · by StemPy Lab
That was the last lessonBack to the course
← Pseudocode, Trace Tables and Testing
← Trace tables and dry runsNext →

Discussion (0)

Log in to join the discussion.

Loading…

1 Python program
5 questions to check yourself

This lesson is free to read. Enroll free to keep your place in the course.

Python Labs (1)

Write a test plan that finds an errorPython Lab · by StemPy Lab

Question Sets (1)

Pseudocode and Testing: Concept Check10 questions · by StemPy Lab