Practical Work and Project
Practical Work and Project reflects the board practical examination: writing and running a Python program, executing SQL queries on supplied tables, and defending a project in a viva. Marks come from correct output, clean code and your ability to explain what you wrote.
Core rules
- A practical answer usually needs three parts: the program or query, the output, and a one-line explanation.
- Python file handling: open(path, "r"/"w"/"a"), then read, readline, readlines or write, then close - or use with open(...) as f: which closes automatically.
- Handle expected failures: FileNotFoundError for a missing file, ValueError when int() receives text, ZeroDivisionError when dividing by zero.
- SQL practicals: quote string values, end statements with a semicolon, and check the table structure before writing a query.
- A project report contains title, aim or synopsis, requirement, design (tables and modules), commented source code, sample output, test cases, limitations and bibliography.
- A test case records input, expected output and actual output; a debugging note names the line and the wrong value.
Worked example
Program to average n numbers: total = 0 for i in range(n): total = total + int(input()) print(total / n)
- Bug 1: n = 0 raises ZeroDivisionError; guard with if n == 0 before dividing.
- Bug 2: if the loop body is not indented, it runs once and total is wrong.
- Test: inputs 10, 20, 30 with n = 3 → total 60, output 20.0.
Traps
- Submitting a report with no output screenshots, or code you cannot explain in the viva.
- Forgetting that input() returns a string, so "10" + "20" gives "1020".
- Leaving files open or ignoring a missing-file error.
- Writing SELECT * with GROUP BY and no aggregate function.