Choosing validation or verification

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

Choosing validation or verification

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. A website asks for an age. The age must be between 11 and 18. Which is needed?
A Validation (a range check), because it tests the age is acceptable
B Verification (double entry), because it tests the age is acceptable
2. A student sets a new password. The system asks them to type it twice. Which is this?
A Validation, because it checks the password is a sensible value
B Verification, because it checks the password was entered correctly
3. Which statement is true?
A Validation checks data is acceptable. Verification checks data was typed correctly.
B Validation checks data was typed correctly. Verification checks data is acceptable.
4. A user types 150 in an age field. The range check is 11 to 18. What happens?
A Validation rejects it because 150 is outside the allowed range
B Verification rejects it because 150 does not match the second entry
5. A user types 15 twice by mistake when they are 14. Will double entry find the error?
A Yes, because double entry proves the data is true
B No, because both entries match even though the age is wrong

Match the Pairs

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

Left columnRight column
1Age field: range check (0 to 120) AA range check is validation, not verification. A new password should use double entry to verify it was typed correctly.
2New password: enter it twice and compare BIF Password1 = Password2 THEN OUTPUT "Passwords match" ENDIF
3Using both gives better protection: validation stops impossible values and verification catches typing slips. CValidation only shows the age is acceptable, not correct. Someone could still mistype 25 instead of 52, so verification may be needed too.
4A justification uses 'because': double entry is needed for a new password because a typing slip could lock the user out. DValidation: it tests that the age entered is acceptable, but it cannot tell if the age is the right one.
5Use a range check to verify a new password was typed correctly. EVerification: double entry checks that the password was typed correctly, because both entries must match.
6Age 25 passes the range check, so the age must be correct. FIF Age >= 0 AND Age <= 120 THEN OUTPUT "Age accepted" ENDIF

Definitions

validation vs verification

Fill in the Blanks

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

1.
INPUT Age IF Age >= 0 ___ Age <= 120 THEN
2.
INPUT Password INPUT Confirm IF Password _ Confirm THEN
3.
// An age range check is __________
4.
REPEAT INPUT Confirm _____ Password = Confirm
5.
// Both checks are used _______ // range finds bad data, double entry typos

Spot the Error

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

Question 1
A INPUT Pass1
B INPUT Pass2
C IF Pass1 = Pass2 THEN
D OUTPUT "Passwords differ"
E ENDIF
Question 2
A INPUT Age
B IF Age < 0 AND Age > 120 THEN
C OUTPUT "Age not valid"
D ENDIF
Question 3
A INPUT Age
B WHILE Age > 11 OR Age < 18 DO
C OUTPUT "Enter 11 to 18"
D INPUT Age
E ENDWHILE
Question 4
A DECLARE Pass1, Pass2 : INTEGER
B INPUT Pass1
C INPUT Pass2
D IF Pass1 <> Pass2 THEN
E OUTPUT "Passwords differ"
F ENDIF
Question 5
A INPUT Email1
B Email2 ← Email1
C WHILE Email1 <> Email2 DO
D OUTPUT "Enter email again"
E INPUT Email2
F ENDWHILE

Answer Key

Choosing validation or verification
Section A: Quick Questions
Q1
A — Validation (a range check), because it tests the age is acceptable
Q2
B — Verification, because it checks the password was entered correctly
Q3
A — Validation checks data is acceptable. Verification checks data was typed correctly.
Q4
A — Validation rejects it because 150 is outside the allowed range
Q5
B — No, because both entries match even though the age is wrong
Section B: Match the Pairs
Q1
Age field: range check (0 to 120) → Validation: it tests that the age entered is acceptable, but it cannot tell if the age is the right one.
Q2
New password: enter it twice and compare → Verification: double entry checks that the password was typed correctly, because both entries must match.
Q3
Using both gives better protection: validation stops impossible values and verification catches typing slips. → IF Age >= 0 AND Age <= 120 THEN OUTPUT "Age accepted" ENDIF
Q4
A justification uses 'because': double entry is needed for a new password because a typing slip could lock the user out. → IF Password1 = Password2 THEN OUTPUT "Passwords match" ENDIF
Q5
Use a range check to verify a new password was typed correctly. → A range check is validation, not verification. A new password should use double entry to verify it was typed correctly.
Q6
Age 25 passes the range check, so the age must be correct. → Validation only shows the age is acceptable, not correct. Someone could still mistype 25 instead of 52, so verification may be needed too.
Section C: Definitions
Q1
validation vs verification — Validation checks data is acceptable, like an age range check. Verification checks it was typed correctly, like double entry. A scenario may need one or both.
Section D: Fill in the Blanks
Q1
INPUT Age IF Age >= 0 AND Age <= 120 THEN
Q2
INPUT Password INPUT Confirm IF Password = Confirm THEN
Q3
// An age range check is validation
Q4
REPEAT INPUT Confirm UNTIL Password = Confirm
Q5
// Both checks are used because // range finds bad data, double entry typos
Section E: Spot the Error
Q1
C — Double entry is verification. The program must warn the user when the two entries do NOT match, so the condition should be Pass1 <> Pass2.
Q2
B — A range check rejects ages outside the range. No number is both below 0 and above 120, so AND never catches anything. It should be OR.
Q3
B — The loop should repeat while the age is outside the range, which is Age < 11 OR Age > 18. With the operators swapped every number is accepted into the loop, so it never ends.
Q4
A — A password can contain letters and symbols, so the variables must be STRING, not INTEGER.
Q5
B — Double entry needs the user to type the second copy. Assigning Email1 to Email2 makes them always match, so it should be INPUT Email2.