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
Standard Algorithms: Totals, Searching, Sorting and Validation
  1. 1Totalling, counting, maximum, minimum and average
  2. 2Linear search and bubble sort
  3. 3Validation and verification
  1. Computer Science
  2. /Standard Algorithms: Totals, Searching, Sorting and Validation
  3. /Validation and verification

Course 7.3·Lesson 3 of 3

Validation and verification

A program must not trust the data a person types. Validation checks that data is sensible: range, length, type, presence and format checks, and the check digit. Verification checks that data was entered as intended: a visual check and a double entry check. You write the checks in pseudocode and Python.

about 25 min1 simulation1 practice question
Lesson 3 of 3Show all lessonsHide
Standard Algorithms: Totals, Searching, Sorting and Validation
  1. 1Totalling, counting, maximum, minimum and average
  2. 2Linear search and bubble sort
  3. 3

Try the code and the simulations beside the lesson.

Rubbish in, rubbish out

A pupil types her age as 150150150. Someone leaves the surname box empty. A shop assistant types a price with a letter in it. If a program accepts data like this, every result after it is wrong. So a program checks its input before it uses it.

Validation

Validation is an automatic check, done by the program, that data is sensible and follows the rules. It cannot tell whether the data is true: an age of 151515 passes a range check even if the pupil is really 141414. The syllabus names six validation checks.

  • Range check: a number is between a lower and an upper limit, for example a mark from 000 to 100100100.
  • Length check: the data has a set number of characters, or a number within limits, for example a password of at least 888 characters.
  • Type check: the data is of the right data type, for example a whole number and not text.
  • Presence check: something has been entered; the box is not empty.
  • Format check: the data has the right pattern of characters, for example two letters then four digits, as in AB1234.
  • Check digit: an extra digit, worked out from the other digits, added to the end of a code. The computer works it out again and compares.

Validation in pseudocode

A range check usually sits in a loop that repeats the input until the value is acceptable. The prompt and an error message help the user.

pseudocode
REPEAT
    OUTPUT "Enter a mark from 0 to 100"
    INPUT Mark
    IF Mark < 0 OR Mark > 100
      THEN
        OUTPUT "Error: the mark must be 0 to 100"
    ENDIF
UNTIL Mark >= 0 AND Mark <= 100

A length check uses LENGTH.

pseudocode
INPUT Password
IF LENGTH(Password) < 8
  THEN
    OUTPUT "Too short: use at least 8 characters"
  ELSE
    OUTPUT "Accepted"
ENDIF

A presence check compares the input with the empty string "".

pseudocode
INPUT Surname
IF Surname = ""
  THEN
    OUTPUT "Please enter your surname"
ENDIF

The check digit

Here is one common method. Each digit is multiplied by a weight, 111 and 333 in turn, and the products are added. The check digit is the number that must be added to make the sum a multiple of 101010. The book numbers called ISBN-13 use this method.

For the code 4,0,1,2,7,24, 0, 1, 2, 7, 24,0,1,2,7,2 the weighted sum is 4+0+1+6+7+6=244 + 0 + 1 + 6 + 7 + 6 = 244+0+1+6+7+6=24. Adding 666 makes 303030. So the check digit is 666, and the full code is 401272640127264012726.

If one digit is typed wrongly, the sum changes and the check digit no longer matches. Swapping two neighbouring digits usually changes the sum too, because they have different weights.

Verification

Verification checks that data has been entered as intended, that it matches what the user meant or what was on the paper. The syllabus names two checks.

  • Visual check: the user looks at the data on the screen and confirms it is right before it is saved.
  • Double entry check: the data is entered twice, and the computer compares the two. If they differ, the data is entered again. Passwords and email addresses are often entered this way.
pseudocode
REPEAT
    OUTPUT "Enter your email address"
    INPUT Email
    OUTPUT "Enter it again"
    INPUT Again
    IF Email <> Again
      THEN
        OUTPUT "They do not match: try again"
    ENDIF
UNTIL Email = Again

Validation and verification work together. Validation stops data that cannot be right. Verification stops mistakes in data that looks sensible.

Practise with new numbers

Try it in Python

The grey blocks marked pseudocode are written in the exam style and do not run. The Python box is the same algorithm in Python, and that one runs. The Python program has one function for each check, and works out the check digit of the code in the lesson.

Read it first. Then run it. Which results are False, and why?

1. Work out the check digit of 401227 by hand, with two digits swapped. Then add a line to print it. Is it still 6?

2. Change format_check so that the code must be three letters and three digits.

Common mistakes

  • Saying validation makes data correct. It only makes data sensible. A wrong but sensible value passes.
  • Mixing up validation and verification. Validation: is it sensible? Verification: was it entered as intended?
  • Mixing up length and range. Length counts characters; range compares the size of a number.
  • No message. A good check tells the user what was wrong and asks again.

Remember these

  • Validation checks: range, length, type, presence, format, check digit.
  • Verification checks: visual check, double entry check.
  • A validation loop repeats the input until the data is acceptable, with an error message.
  • A check digit is worked out from the other digits and checked again on entry.

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 refuses a postcode box that is left empty. Which check is this?
  1. A program refuses the year 302530253025 as a date of birth. Which check is this?
  1. A user types a new password twice, and the computer compares them. Is this validation or verification? Which check is it?
  1. A code must be three letters followed by two digits. Which check tests this?
  1. Work out the check digit of 3,5,2,13, 5, 2, 13,5,2,1 with the weights 1,3,1,31, 3, 1, 31,3,1,3.

References

  • Cambridge International, IGCSE Computer Science 0478 syllabus (2026, 2027 and 2028), unit 7, part 5: validation and verification checks.

Enroll free in Standard Algorithms: Totals, Searching, Sorting and Validation

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)

Name the check in each case. Say whether it is validation or verification…Easy · High School (9–10) · by StemPy Lab
A delivery company adds a check digit to each parcel number…Medium · High School (9–10) · by StemPy Lab
This is the kind of long scenario question that ends Paper 2…Hard · High School (9–10) · by StemPy Lab
That was the last lessonBack to the course
← Standard Algorithms: Totals, Searching, Sorting and Validation
← Linear search and bubble sortNext →

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.

Validation and verification

Question Sets (1)

Standard Algorithms: Test Yourself10 questions · by StemPy Lab