In this guide:
Exam Strategy: Verification vs. Validation
Cambridge examiners frequently ask students to describe the difference between Verification and Validation. Do not get these mixed up!
Python vs. Pseudocode Validation
In Python, programmers often use an infinite while True: loop combined with a break statement to trap a user until they enter correct data. In Cambridge pseudocode, you must use a REPEAT...UNTIL loop.
| Concept | 🐍 Python (Wrong for Exams) | 📘 Cambridge Pseudocode (Correct) |
|---|---|---|
| Validation Loop | while True: x = int(input()) if x > 0: break |
REPEAT INPUT X UNTIL X > 0 |
1. The 3 Core Validation Checks
You need to memorize the code for these three specific validation methods:
IF Score >= 0 AND Score <= 100 THEN...
IF LENGTH(Password) > 8 THEN...
IF Name <> "" THEN...
2. Writing a Validation Loop
A true robust program doesn't just crash when the user enters bad data; it traps the user in a loop until they get it right. You should always use the REPEAT...UNTIL structure for this.
DECLARE Choice : INTEGER
// The user is trapped until they enter 1 or 2
REPEAT
OUTPUT "Enter 1 to Start, 2 to Quit:"
INPUT Choice
IF Choice <> 1 AND Choice <> 2 THEN
OUTPUT "Error: Invalid choice!"
ENDIF
UNTIL Choice = 1 OR Choice = 2
OUTPUT "Proceeding with option ", Choice
Interactive Exam Practice
Scenario: Write an algorithm that asks a teacher to input a student's test score. Implement a Range Check validation loop to ensure the score is between 0 and 100 inclusive. Keep asking until a valid score is provided.
Hover or tap the black box to reveal the examiner's solution. Click Run Code to test it instantly!
DECLARE Mark : INTEGER REPEAT OUTPUT "Enter a valid mark (0 to 100):" INPUT Mark UNTIL Mark >= 0 AND Mark <= 100 OUTPUT "Score accepted and recorded."