2 missions. Guess, learn, then check. Your place is saved.
The specification points and sources are listed under the lesson: see Sources.
Make a guess: You typed 41, not 14, for your age. Why did the form accept it?
| Check | What it tests | Example |
|---|---|---|
| Range check | a number is between limits | age 0 to 120 |
| Length check | number of characters | password at least 8 |
| Presence check | something was entered (not empty) | surname not blank |
score = int(input("Score 1 to 10: "))
while score < 1 OR score > 10
score = int(input("Must be 1 to 10: "))
endwhilename = input("Name: ")
while name.length < 3
print("Too short")
name = input("Name: ")
endwhile
print("Hello " + name)username = input("Username: ")
password = input("Password: ")
if username == "sam01" AND password == "Tr33house" then
print("Access granted")
else
print("Access denied")
endifValidation checks that data is reasonable, such as an age from 0 to 120. 41 follows that rule, so it is accepted even though it is wrong. Only a person who knows the right answer can spot that 41 is the wrong age.
Make a guess: It passed every test. So why did it fail for an 18-year-old?
For a program that accepts whole numbers from 1 to 10:
age = int(input("Age: "))
if age > 18 then
print("Adult ticket")
else
print("Child ticket")
endif| Test | Data | Type | Expected | Actual |
|---|---|---|---|---|
| 1 | 5 | Normal | Accepted | Accepted |
| 2 | 10 | Boundary | Accepted | Rejected |
| 3 | 11 | Invalid | Rejected | Rejected |
| 4 | ten | Erroneous | Rejected | Rejected |
The code used > 18 when the rule needed ≥ 18, a mistake that only shows at exactly 18. Testing 10, 30 and 50 only tried normal values; a test at the edge of the range would have caught it.
You've worked through Producing robust programs for OCR GCSE Computer Science (J277). 🎉
Your stars: 0 / 0
Next: test yourself in the Verify stage.
→ Back to GCSE Computer Science · OCR
Specification points and sources for this lesson are listed at the bottom of the page.
The specification points and sources behind this lesson.