These questions are written in the style of SQA N5 Computing Science past papers. They are grouped by specification area (1.1–1.8). Work through each section, write your answer, then reveal the marking notes. Use the score tracker to record your marks as you go.
Name the iterative development process used at National 5 level and state how many stages it has.
Award 1 mark for: Iterative development process / software development process (accept "iterative" or "six-stage development process"). Must state 6 stages. Award 0 if only the name of one stage is given.
Example answer: The iterative development process — it has 6 stages: analysis, design, implementation, testing, documentation, and evaluation.
Explain what is meant by the term "iterative" in the context of the software development process.
Award 1 mark each for two of:
- The process can repeat / go back to previous stages
- If a problem is found (e.g. during testing), the developer returns to an earlier stage (e.g. design or implementation)
- The process loops until the software meets all requirements
- Evaluation may identify new requirements, restarting the cycle
During which stage of the development process would a programmer decide to use an array to store a list of names?
A school wants a program to manage its after-school clubs. Identify one input, one process, and one output for this program.
Award 1 mark for each of:
Input (1 mark): Pupil name / club name / number of places / pupil registration number (any reasonable input)
Process (1 mark): Check if places are available / add pupil to waiting list / count total members / search for a pupil's clubs (any reasonable process)
Output (1 mark): Confirmation that the pupil has been added / list of available clubs / number of remaining places (any reasonable output)
Describe what is meant by a "functional requirement" for a software solution.
Award 1 mark each for two of:
- A specific thing the software must do / be able to do
- Describes the inputs, processes, and outputs required
- Comes from the client's specification / what the client asked for
- Something the developer can test — either the software does it or it doesn't
Example: "The program must accept a pupil's name and display a list of clubs they are registered for" is a functional requirement.
Name one design notation used to plan the logic of a program before it is coded.
Write pseudocode for a program that: (a) asks the user to enter 5 test scores, (b) validates each score so that it must be between 0 and 100, (c) keeps a running total, and (d) displays the average score at the end.
Award 1 mark each for:
- FOR loop that iterates 5 times (or equivalent)
- Input validation using WHILE with correct condition (
score < 0 OR score > 100) - Running total accumulator (
SET total TO total + score) - Average calculation and SEND to DISPLAY
SET total TO 0
FOR counter FROM 1 TO 5 DO
RECEIVE score FROM (INTEGER) KEYBOARD
WHILE score < 0 OR score > 100 DO
SEND "Invalid. Enter score 0-100." TO DISPLAY
RECEIVE score FROM (INTEGER) KEYBOARD
END WHILE
SET total TO total + score
END FOR
SET average TO total / 5
SEND "Average score: " & average TO DISPLAY
A programmer uses a structure diagram to design a program. Describe what a structure diagram shows.
Award 1 mark each for two of:
- Uses symbols for process, loop, selection, and predefined-process steps
- Represents the steps of an algorithm and how those steps are structured
- Is read from top to bottom and, where steps branch at the same level, from left to right
- Can show where repetition or selection occurs in the algorithm
A structure diagram is a design notation for algorithm steps; it is not a module-call hierarchy.
A programmer stores the value 3.14 in a variable. What data type should be used?
A program stores the names of 6 pupils in an array called pupils.
(a) Write the Python code to declare the array and store the names "Ali", "Beth", "Cal", "Dana", "Eve", "Finn".
(b) Write Python code to display the third name in the array.
(c) State what index the last element has.
(a) 1 mark:
pupils = ["Ali", "Beth", "Cal", "Dana", "Eve", "Finn"]
(b) 1 mark:
print(pupils[2])
(index 2 = third element, because arrays/lists are zero-indexed in Python)
(c) 1 mark: Index 5. A 6-element array has indices 0–5. Last element = length − 1 = 6 − 1 = 5.
Explain the difference between a variable and an array.
Award 1 mark for each of:
- A variable stores a single value; an array stores multiple values of the same type
- Array elements are accessed using an index (position number, starting at 0); a variable is accessed by its name alone
A program must repeat a block of code while the user's answer is wrong. The number of repetitions is not known in advance. Which loop construct is most appropriate?
The following Python code has three errors. Identify each error and state how to fix it.
score = int(input("Enter score: "))
if score =< 0:
print("too low)
elif score > 100
print("too high")
else:
print("Valid score")
Award 1 mark each for identifying and fixing:
- Error 1:
=<is not valid Python. Fix: change to<=(less-than-or-equal-to). - Error 2: Missing closing quote in
"too low)— the string is not closed. Fix:"too low") - Error 3: Missing colon at the end of
elif score > 100. Fix:elif score > 100:
A program uses a predefined function called round(). State what is meant by a predefined function and give one benefit of using it.
Award 1 mark for definition: A predefined function is a function that is already written and built into the programming language — the programmer can use it without having to write the code themselves.
Award 1 mark for benefit (any one):
- Saves time — the programmer does not have to write the code themselves
- Reduces errors — the function has already been tested and is reliable
- Improves readability — a single function call is easier to read than many lines of code
- Can be used multiple times in the same program without repeating code
Complete the Python code below so that it traverses the array scores and prints each value on a new line.
scores = [45, 72, 88, 61, 53]
for _____ in range(_____):
print(_____)
scores = [45, 72, 88, 61, 53]
for index in range(5):
print(scores[index])
Award 1 mark for the loop variable and range (accept range(len(scores))); 1 mark for scores[index] or scores[i] (any valid index variable).
Alternative accepted: for score in scores: print(score) — award 2 marks.
Which of the following is one of the three standard algorithms named in the N5 specification?
An array called temps stores 7 daily temperature readings: [12, 8, 15, 6, 19, 11, 14].
(a) Write Python code that traverses the array and uses a running total within the loop to calculate the sum of all readings.
(b) Trace the value of total after each iteration and state the final output.
(a) 3 marks — award 1 each for: initialising total to 0 before the loop; traversing every array element; updating total inside the loop.
temps = [12, 8, 15, 6, 19, 11, 14]
total = 0
for index in range(len(temps)):
total = total + temps[index]
print("Total:", total)
(b) 1 mark: total values after each iteration: 12, 20, 35, 41, 60, 71, 85. Final output: Total: 85.
Write pseudocode for the input validation algorithm that accepts a user's age, ensuring it is between 4 and 18 inclusive.
Award 1 mark each for:
- Initial RECEIVE before the loop (read-before-loop pattern)
- WHILE condition using correct range AND logical operator:
age < 4 OR age > 18 - RECEIVE inside the loop (re-prompt)
RECEIVE age FROM (INTEGER) KEYBOARD
WHILE age < 4 OR age > 18 DO
SEND "Invalid. Enter age between 4 and 18." TO DISPLAY
RECEIVE age FROM (INTEGER) KEYBOARD
END WHILE
Common error: Using AND instead of OR in the WHILE condition. The condition must be true when the input is bad: age is bad if it is less than 4 or greater than 18.
Complete the trace table below for the find-minimum algorithm running on the array [8, 3, 11, 2, 7]. The initial minimum is set to index 0.
| Iteration | index | current value | minimum so far |
|---|---|---|---|
| Start | 0 | 8 | 8 |
| 1 | 1 | 3 | |
| 2 | 2 | 11 | |
| 3 | 3 | 2 | |
| 4 | 4 | 7 |
Award 1 mark for each row that changes the minimum:
| Iteration | index | current value | minimum so far |
|---|---|---|---|
| Start | 0 | 8 | 8 |
| 1 | 1 | 3 | 3 (3 < 8) |
| 2 | 2 | 11 | 3 (11 > 3 — no change) |
| 3 | 3 | 2 | 2 (2 < 3) |
| 4 | 4 | 7 | 2 (7 > 2 — no change) |
Final minimum = 2.
A program accepts ages between 16 and 65 inclusive. Which of the following is an example of boundary test data?
A program accepts a percentage score (0–100) and awards a grade: A (70–100), B (50–69), C (30–49), Fail (<30). Design a test table with one example of each type of test data (normal, boundary, and exceptional). For each test, state the input, expected output, and type.
Award 1 mark each for (up to 4 marks):
| Test | Input | Expected output | Type |
|---|---|---|---|
| 1 | 75 | Grade A | Normal |
| 2 | 70 | Grade A | Boundary (lower boundary of A) |
| 3 | 69 | Grade B | Boundary (upper boundary of B) |
| 4 | 0 | Fail | Boundary (lower boundary of range) |
| 5 | 101 | Error / Invalid input message | Exceptional (out of range) |
| 6 | "sixty" | Error / Invalid input message | Exceptional (wrong data type) |
Any reasonable test table accepted, as long as: at least one normal, at least one boundary, at least one exceptional, and expected outputs are correct.
Explain the difference between a syntax error and a logic error.
Award 1 mark each for:
- Syntax error: A mistake in the grammar / spelling / punctuation of the code that prevents the program from running. Detected by the interpreter/compiler before execution. Example: missing colon, misspelled keyword, unmatched bracket.
- Logic error: The code runs without crashing but produces the wrong result. The programmer has made an error in the logic / algorithm. Example: using
ANDinstead ofORin input validation, using<instead of<=.
Which evaluation criterion asks: "Does the program do what the client asked it to do?"
Evaluate the program below against the criteria of readability and efficient use of coding constructs. Your answer must refer to specific lines or features of the code.
x=int(input("?"))
if x>0:
print("pos")
if x<0:
print("neg")
if x==0:
print("zero")
Award up to 2 marks for readability:
- No internal comments — a comment explaining the purpose of the program would improve readability
- Variable name
xis not meaningful — should be renamednumberoruserValue - Input prompt
"?"is not descriptive — the user does not know what to enter - No white space between the IF statements
- Output strings ("pos", "neg", "zero") are abbreviated and not meaningful to the user
Award up to 2 marks for efficient use:
- Three separate IF statements are used. This is inefficient because all three conditions are always evaluated.
- If
xis 5 (positive), condition 1 is True — but conditions 2 and 3 are still checked unnecessarily. - Using ELSE IF (elif) would be more efficient — once a match is found, the remaining conditions are skipped.
A program accepts a numeric value and calculates its square root using math.sqrt(). It does not validate whether the number is negative. Evaluate the robustness of this program.math.sqrt() is supplied as context for this question; it is not a function you are required to memorise at N5.
Award 1 mark for identifying the problem: The program is not robust for negative numeric values. Calling math.sqrt() with a negative number raises ValueError, because the square root is not defined as a real number, and the program crashes.
Award 1 mark for suggesting an improvement: Add input validation using a WHILE loop so the program only calls math.sqrt() when number >= 0. Example rejection condition: while number < 0, with an error message and another numeric input inside the loop.
The SDD question paper section is typically worth 25–30 marks. Questions are roughly balanced across the 8 spec areas but 1.4, 1.5, and 1.6 usually have the highest mark allocations because they are the largest spec areas.
Questions are expressed in SQA reference language, so you must be able to read forms such as RECEIVE x FROM (INTEGER) KEYBOARD, SEND "text" TO DISPLAY, SET x TO value, FOR ... / END FOR, and WHILE ... / END WHILE. When a question asks you to write code, you may use any programming language; marks reward correct understanding and logic rather than exact reference-language syntax.
For evaluation questions: name the criterion, state your judgement, justify with specific evidence from the code. Never give a vague answer — quote variable names, line features, or specific constructs.
Suggested use: This lesson works best as a revision class or post-assessment activity rather than a first-teach lesson. Pupils can work at their own pace through each spec section, spending more time on their weaker areas.
Score tracker: Pupils should manually click +1 for each mark they earn after revealing the marking notes. After completing the full set (total possible ~45 marks), you can discuss which spec areas had the most drops as a class.
Known difficult questions: Q7 (pseudocode with validation + running total), Q17 (array traversal with running-total trace), Q21 (test table design), Q24 (evaluation of both readability and efficient use). Allow extra time for these.
Q13 (error spotting): This is a deliberately tricky question — pupils must spot =< (operator order), a missing closing quote, and a missing colon. These are three of the most common syntax errors in pupil Python code.