Validation versus verification

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Validation versus verification

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. Which check confirms that an entered age is a number between 0 and 120?
A Validation
B Verification
2. Which check confirms that the data typed in matches the original paper form?
A Verification
B Validation
3. A student enters 25 as their age, but their paper form says 15. Both values pass a range check. Which statement is true?
A Verification passes but validation would catch the error
B Validation passes but verification would catch the error
4. Proofreading entered data against the source document is an example of:
A Verification
B Validation
5. A program rejects an empty email field with an existence check. This is:
A Verification
B Validation

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1if age < 0 or age > 120: Aif name == "": print("Name is required")
2if entered == source_copy: BProofreading is verification: it compares the entered data with the source. It does not test whether a value is reasonable or in range.
3Validation checks that data is reasonable and complete, for example that a required field is not empty Cif email1 != email2: print("Entries do not match")
4Verification by double entry: the user types the data twice and the two entries must match DValidation: a range check that tests whether the entered age is reasonable
5if mark >= 0 and mark <= 100: print("Verified: matches the source") EVerification: checks that the entered data matches the original source data
6Proofreading confirms a value is within an allowed range. FA range check is validation, not verification. It checks the mark is reasonable but does not compare it to the source data.

Definitions

validation vs verification

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
if 0 <= age __ 120:
2.
email = input("Email: ") again = input("Re-enter email: ") if email __ again:
3.
if ___(name) > 0:
4.
if age < 0 __ age > 120: print("Invalid age")
5.
source = "Ava Nguyen" typed = input("Retype name: ") print(______ == typed)

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A def is_valid_age(age)
B return 0 <= age <= 120
C print(is_valid_age(25))
Question 2
A pw1 = input('Password: ')
B pw2 = input('Re-enter: ')
C if pw1 = pw2:
D print('Verified')
Question 3
A mark = int(input('Mark: '))
B if mark >= 0 or mark <= 100:
C print('Valid')
D else:
E print('Invalid')
Question 4
A name = input('Name: ')
B while name == '':
C name == input('Name: ')
D print('Hello', name)
Question 5
A source = 'S1042'
B typed = inpt('ID: ')
C if typed == source:
D print('Matches source')

Answer Key

Validation versus verification
Section A: Quick Questions
Q1
A — Validation
Q2
A — Verification
Q3
B — Validation passes but verification would catch the error
Q4
A — Verification
Q5
B — Validation
Section B: Match the Pairs
Q1
if age < 0 or age > 120: → Validation: a range check that tests whether the entered age is reasonable
Q2
if entered == source_copy: → Verification: checks that the entered data matches the original source data
Q3
Validation checks that data is reasonable and complete, for example that a required field is not empty → if name == "": print("Name is required")
Q4
Verification by double entry: the user types the data twice and the two entries must match → if email1 != email2: print("Entries do not match")
Q5
if mark >= 0 and mark <= 100: print("Verified: matches the source") → A range check is validation, not verification. It checks the mark is reasonable but does not compare it to the source data.
Q6
Proofreading confirms a value is within an allowed range. → Proofreading is verification: it compares the entered data with the source. It does not test whether a value is reasonable or in range.
Section C: Definitions
Q1
validation vs verification — Validation checks entered data is reasonable and complete. Verification checks it matches the source data, for example by proofreading.
Section D: Fill in the Blanks
Q1
if 0 <= age <= 120:
Q2
email = input("Email: ") again = input("Re-enter email: ") if email == again:
Q3
if len(name) > 0:
Q4
if age < 0 or age > 120: print("Invalid age")
Q5
source = "Ava Nguyen" typed = input("Retype name: ") print(source == typed)
Section E: Spot the Error
Q1
A — A validation function is a normal function, so the def line must end with a colon: def is_valid_age(age):
Q2
C — Double entry verification compares the two entries. = assigns a value and is invalid in an if condition. Use == to compare.
Q3
B — This range check must use and, because a mark has to be at least 0 and at most 100. With or, every number passes, so invalid data is never rejected.
Q4
C — This existence check must store the new input. == only compares, so name never changes and the loop never ends. It should be name = input('Name: ').
Q5
B — The function name is misspelled. It must be input(), otherwise Python raises a NameError and the typed data can't be verified against the source.