Level:
Correct: 0
Incorrect: 0
Marks: 0/0
Exam Practice
Subject:
Topics:
Avg
score:
–
Topics
done:
0/32

Test data

Practise 29 exam-style questions on Test data for Cambridge IGCSE Computer Science (Paper 2). Write your answer as you would in the exam and get it marked in seconds against the mark scheme, point by point, with an AI tutor on hand if you get stuck.

  • 29 questions
  • 1–6 marks each
  • Instant marking
  • No sign-up needed
20 questions, marked as you go

Sample questions with model answers

Here are 4 of the questions in this topic, each with a model answer, an explanation of why it earns the marks and the mark scheme an examiner would use.

Question 1

1 mark

A program asks the user to enter a whole number from 1 to 50. The user types the word ten.

State the type of test data this is.

Model answer

Abnormal data

Explanation

The program expects a number, so text is the wrong data type and should be rejected. Data that should be rejected is abnormal data. Testing with it checks that the program does not crash or accept nonsense input.

Mark scheme
  1. 1 mark

    Abnormal (test) data

    Accept: erroneous data.

Question 2

2 marks

Explain why a program should be tested using abnormal data.

Model answer

Abnormal data checks that the program rejects data that is invalid, so the validation routines work. It also shows that the program handles invalid input sensibly, for example by outputting an error message, instead of crashing or storing incorrect data.

Explanation

Users will sometimes type the wrong thing, so a program must cope with it. Testing with abnormal data, such as values outside the range or of the wrong type, proves the validation catches these inputs. A program tested only with valid data might fail as soon as a user makes a mistake.

Mark scheme
  1. 1 mark

    To check that invalid data is rejected / that the validation works

  2. 1 mark

    To make sure the program does not crash or produce incorrect results when invalid data is entered, e.g. it outputs a suitable error message instead

Question 3

3 marks

This algorithm should accept whole numbers from 1 to 12.

REPEAT
    OUTPUT "Enter the number of guests (1 to 12)"
    INPUT Guests
UNTIL Guests > 1 AND Guests <= 12

When the algorithm is tested with extreme data, one of the tests shows that there is an error.

State the extreme test value that shows the error, describe what happens when it is entered, and write a corrected version of the last line.

Model answer

The value 1 shows the error. When 1 is entered, the condition 1 > 1 is false, so the loop repeats and the user is asked again, although 1 should be accepted.
Corrected line: UNTIL Guests >= 1 AND Guests <= 12

Explanation

Extreme data tests the smallest and largest acceptable values, here 1 and 12. The value 12 is accepted correctly, but 1 is rejected because the condition uses > instead of >=. This is exactly the kind of error that normal data, such as 6, would never reveal.

Mark scheme
  1. 1 mark

    1

  2. 1 mark

    1 is rejected / the user is asked to enter the number of guests again, even though it should be accepted

  3. 1 mark

    UNTIL Guests >= 1 AND Guests <= 12

    Accept UNTIL Guests > 0 AND Guests <= 12, or ≥ for >=.

Question 4

5 marks

A sports app asks a user to enter the number of minutes they exercised, a whole number from 1 to 90.

Write pseudocode using a REPEAT ... UNTIL loop to input and validate the number of minutes, outputting an error message for any invalid input. Then give the two values of boundary test data for the upper limit and the expected outcome of each.

Model answer

REPEAT
    OUTPUT "Enter minutes of exercise (1 to 90)"
    INPUT Minutes
    IF Minutes < 1 OR Minutes > 90
      THEN
        OUTPUT "Invalid: enter a whole number from 1 to 90"
    ENDIF
UNTIL Minutes >= 1 AND Minutes <= 90

Boundary test data for the upper limit: 90 should be accepted and 91 should be rejected.

Explanation

The REPEAT ... UNTIL loop keeps asking until the value is in range, and the IF inside gives an error message only for invalid input. The boundary pair for the upper limit is the largest acceptable value (90) and the smallest rejected value (91). Testing both shows the condition uses <= 90 correctly.

Mark scheme
  1. 1 mark

    MP1 prompts for and inputs the minutes inside a REPEAT ... UNTIL loop

  2. 1 mark

    MP2 the loop ends only when Minutes >= 1 AND Minutes <= 90 (or equivalent)

  3. 1 mark

    MP3 outputs an error message only when the input is invalid

  4. 1 mark

    MP4 90 - accepted

  5. 1 mark

    MP5 91 - rejected

Ready to try the rest? Every answer you write is marked against the mark scheme, so you can see exactly where the marks are.

AI Tutor Hints first, answers after you try

Hi! Stuck? Ask me for a hint and I’ll help you work it out. Once you’ve checked your answer I can explain exactly where the marks are.