← QCE Digital Solutions Unit 2

Reliability of a solution

A reliable solution gives correct results every time and keeps working when input is bad or an error occurs, so no data is lost.

Understanding Reliability of a solution in QCE Digital Solutions Unit 2

What it does: A fixed, precise query returns the same result each time it is run on the same data, which shows repeatable results. The loop rejects invalid input and asks again, so the program keeps working when the user makes a mistake. Reliable solutions protect data when an error occurs. Half-finished changes should not leave the data damaged. Users make mistakes, so a reliable solution must cope with bad input as well as good input. Testing reliability means trying bad input and repeating tests, not just checking one valid case. Use try/except around the query and call conn.commit() on success, or conn.rollback() on failure, so no data is lost.

Common mistakes: The loop never asks for new input, so bad input stays in age and the loop never ends. The line should be age = input('Again: ') so the user can fix their entry. Without int() the text is never converted, so no ValueError is raised and bad input is accepted as if it were a number. It should be n = int(input('Num: ')).

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 337–409) and word search (Modules 234–409).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
Which solution is MORE reliable?
A program that shows a friendly message when a user types letters instead of a numberA program that crashes when a user types letters instead of a number
Matches
qty = int(input('Qty: '))
↓
There is no error handling. If the user types letters, int() raises a ValueError and the program crashes, so it is not reliable.
Applying
Meanings
Term
reliability
Meaning
A reliable solution gives correct results every time and keeps working when input is bad or an error occurs, so no data is lost.
Practice
value = "abc"
Testing
Gaps
except :
Check Answer
Spots
2while not age.isdigit():
3 print('Again: ')

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Manta Ray' badge — Graceful Coder, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. Which solution is MORE reliable?
A. A program that shows a friendly message when a user types letters instead of a number ✓
B. A program that crashes when a user types letters instead of a number
A reliable solution keeps working when input is bad. It handles invalid input instead of crashing.
2. A student's quiz app gives the same total score every time the same answers are entered. What does this show?
A. The solution is not reliable because it never changes
B. Repeatable results, so the solution is reliable ✓
Reliability means correct results every time. The same input should always give the same correct output.
3. A program crashes halfway through saving an order. Which outcome is reliable?
A. The half-saved order is rolled back and no data is lost or corrupted ✓
B. The half-saved order stays in the database in a broken state
Reliable solutions protect data when an error occurs. Half-finished changes should not leave the data damaged.
4. Which Python code makes a solution more reliable when reading a number?
A. try: age = int(input()) except ValueError: print('Enter a number') ✓
B. age = int(input())
try/except catches the error from bad input so the program keeps running instead of crashing.
5. Which statement about reliability is TRUE?
A. A reliable solution only needs to work when the user enters perfect data
B. A reliable solution gives correct results every time it is run ✓
Users make mistakes, so a reliable solution must cope with bad input as well as good input.

Match the Pairs

try: qty = int(text) except ValueError: qty = 0 → Handles invalid input so the program keeps running instead of crashing
conn.commit() → Saves changes to the database so the data is not lost after the program ends
A reliable solution gives repeatable results: the same query on the same data gives the same answer every time → SELECT COUNT(*) FROM students WHERE house = 'Red';
A reliable solution keeps asking until the input is valid, so bad input does not break it → while not age.isdigit(): age = input('Age: ')
qty = int(input('Qty: ')) → There is no error handling. If the user types letters, int() raises a ValueError and the program crashes, so it is not reliable.
cur.execute(sql) # no commit or error check → The change is never committed and errors are not handled, so data can be lost if the program ends or fails part way through.

Key Term

reliability
A reliable solution gives correct results every time and keeps working when input is bad or an error occurs, so no data is lost.

Fill in the Blanks

1. try: age = int(input("Age: ")) except ValueError:
Hint: Type the error type raised when text cannot be converted to a number, so the program keeps running on bad input
2. while not age.isdigit(): age = input("Enter digits: ")
Hint: Type the string method that checks whether every character is a digit, so the loop repeats until the input is valid
3. except sqlite3.Error: conn.rollback()
Hint: Type the connection method that undoes unsaved changes when an error happens, so no data is left half-changed
4. cur.execute(sql, (name, mark)) conn.commit()
Hint: Type the connection method that permanently saves the change to the database so the data is not lost
5. assert total(2, 3) == 5
Hint: Type the operator that checks the result equals the expected value, proving the same input gives the same output each time

Spot the Error

Question 1
A age = input('Age: ')
B while not age.isdigit():
C print('Again: ')
D age = int(age)
Line C — The loop never asks for new input, so bad input stays in age and the loop never ends. The line should be age = input('Again: ') so the user can fix their entry.
Question 2
A try:
B n = input('Num: ')
C except ValueError:
D print('Not a number')
Line B — Without int() the text is never converted, so no ValueError is raised and bad input is accepted as if it were a number. It should be n = int(input('Num: ')).
Question 3
A try:
B cur.execute(sql, data)
C con.commit()
D except ValueError:
E con.rollback()
Line D — A database failure raises sqlite3.Error, not ValueError. The rollback would never run, so a half-finished change could be left in the database. It should be except sqlite3.Error:.
Question 4
A SELECT name, price
B FROM products
C ORDER BY RANDOM();
Line C — RANDOM() puts the rows in a different order each run, so the results are not repeatable. Ordering by real columns gives the same output every time.
Question 5
A while False:
B s = input('Mark: ')
C if s.isdigit():
D break
E print('Valid mark')
Line A — With while False the loop body never runs, so the input is never asked for or checked. It should be while True: and then break once the input is valid.

Student with a class code? Join your class →