Skip to content
IGCSE·Tuition
Computer Science · Practice

Validation, verification and testing: mixed practice

You can recite the definitions, and then a question hands you a fresh scenario with a table to complete.

This set covers the whole validation, verification and testing module: choosing validation checks, telling validation from verification, designing test data, predicting results by tracing and finding untested branches. All scenarios are fictional.

Questions run from easy to harder. Write your answer first, then open the working. The restricted pseudocode trace trainer helps with the tracing questions, and the mistake log and retest queue is the place to record slips.

Questions

1. A form says: “A username must have 6 to 12 characters.” Name the validation check.

Show answer

A length check. It counts the characters, with a minimum of 6 and a maximum of 12.

2. A website asks the user to type their email address twice and compares the two. Is this validation or verification? Name the method.

Show answer

Verification, by double entry. The program compares two copies to confirm the user typed what they meant.

3. A product code must be three letters followed by two digits, such as ABC12. Name the check. Does XYZ99 pass? Does AB123 pass?

Show answer

A format check. XYZ99 passes because it is three letters then two digits. AB123 fails because it is two letters then three digits.

4. A range check accepts ages 13 to 17. A member’s true age is 15 but 14 is typed. Is it accepted? What could catch the mistake?

Show answer

Yes, 14 is accepted, because 13 <= 14 <= 17. Validation cannot know the true age. Verification, such as double entry or a visual check against the source, could catch it.

5. A rule says: “Percentage must be a whole number from 0 to 100 inclusive.” Complete a test table with normal, boundary and invalid data and the expected result for each.

Show answer
TypeTest valueExpected result
Normal55Accepted
Boundary0Accepted
Boundary100Accepted
Boundary, just outside-1Rejected
Boundary, just outside101Rejected
Invalid“fifty”Rejected

6. Trace this algorithm and state the output.

X ← 3
Y ← 0
WHILE X > 0
  Y ← Y + X
  X ← X - 1
ENDWHILE
OUTPUT Y
Show answer
LoopX beforeY afterX after
1332
2251
3160

Now X > 0 is FALSE and the loop ends. The output is 6.

7. This code should accept percentages 0 to 100 inclusive. Which test values from question 5 make it fail, and why?

INPUT Percent
IF Percent > 0 AND Percent < 100 THEN
  OUTPUT "Accepted"
ELSE
  OUTPUT "Rejected"
ENDIF
Show answer

0 and 100 fail. Expected Accepted, but 0 > 0 is FALSE and 100 < 100 is FALSE, so the output is “Rejected”. The code should use >= and <=. The normal value 55 passes, which hides the fault.

8. Predict the output before running, using a trace table. The inputs are 5, 12, 10, 20.

Count ← 0
FOR I ← 1 TO 4
  INPUT Value
  IF Value > 10 THEN
    Count ← Count + 1
  ENDIF
NEXT I
OUTPUT Count
Show answer
IValueValue > 10Count
15FALSE0
212TRUE1
310FALSE1
420TRUE2

The output is 2. The value 10 is not greater than 10.

9. Predict the output for the inputs 150, -2, 40.

REPEAT
  INPUT Mark
  IF Mark < 0 OR Mark > 100 THEN
    OUTPUT "Invalid"
  ENDIF
UNTIL Mark >= 0 AND Mark <= 100
OUTPUT Mark
Show answer

150 > 100 so “Invalid” is output and the loop continues. -2 < 0 so “Invalid” is output again. 40 passes both checks, so the loop ends and 40 is output. The full output is: Invalid, Invalid, 40.

10. A ticket program gives price 5 for age under 12, price 10 for ages 12 to 59 and price 7 for 60 and over. Tests so far use ages 8 and 30. Which branch is untested, and what test would you add?

INPUT Age
IF Age < 12 THEN
  Price ← 5
ELSE
  IF Age < 60 THEN
    Price ← 10
  ELSE
    Price ← 7
  ENDIF
ENDIF
OUTPUT Price
Show answer

Age 8 reaches the first branch (price 5). Age 30 reaches the second (price 10). The ELSE branch for ages 60 and over is untested. Add Age = 60, expected price 7. Boundary tests 11, 12, 59 and 60 should give 5, 10, 10 and 7.

11. Write pseudocode that asks for a password until it has at least 8 characters. Then say what must also happen to verify it.

Show answer
REPEAT
  INPUT Password
  IF LENGTH(Password) < 8 THEN
    OUTPUT "At least 8 characters needed"
  ENDIF
UNTIL LENGTH(Password) >= 8

This is a length check, so it is validation. To verify, the user types the password a second time and the program compares the two entries. If they differ, it asks again.

If you got these wrong

SlipGo to
Named the wrong check, or confused range and lengthChoosing a validation rule
Wrote that validation makes data correctVerification and validation
Missed a boundary or chose only normal dataDesigning test data
Trace table gave the wrong outputExplaining an expected result
Said a program was tested when a branch was never runIdentifying an untested branch

Log each slip in the mistake log and retest queue and retry the question after a few days. If one error type keeps returning, that is a good topic to bring to online one-to-one Computer Science tuition.

Questions people ask

How should I use this practice set?

Write each answer on paper as you would in an exam before opening the worked answer. Compare key terms, not just ideas, then log each slip. Retry the missed questions a few days later without notes to see whether the correction held.

Are these questions from past papers?

No. Every question is original and uses fictional scenarios. They match the skills in this module, not any particular paper. Past papers and the syllabus are available from your exam centre and the Cambridge website.

Should I answer in pseudocode or Python?

The code here is Cambridge-style pseudocode. If your course uses Python, translate the same logic, since the checks and traces do not change. Follow whichever notation your question or teacher requires.

Updated:

Your next step

If the slips in this set repeat, a one-to-one teacher can sort them into causes and build a short plan around the two or three that cost you the most.

Paid one-hour trial at your assigned teacher’s confirmed rate, starting from RM80. Other fees, schedules and ongoing arrangements are confirmed directly with your teacher after the trial class.

Tuition is arranged with a parent or guardian. Send them this page on WhatsApp and they can enquire for you.

Parent or guardian? Enquire here

9,000+ students helped through our service