Term 1 check-in
Answers are for parents and teachers.
1
Trace this pseudocode when the user types 4, and write the output. Then say what it outputs for 1.
Pseudocode
1INPUT boxes 2total ← boxes * 3 3IF total > 10 THEN 4 OUTPUT "Big order" 5ELSE 6 OUTPUT "Small order" 7ENDIF
For 4: total ← 4 × 3 = 12, and 12 is more than 10, so the output is Big order. For 1: total is 3, so the output is Small order.
2
Write a Python program that asks for a mark out of 100 and prints Merit for 70 or more, Pass for 40 to 69, and Keep practising for less than 40. Test it with 70, 69, 40 and 39.
Model answer (lines are separated by /, and [indent] means four spaces at the start of the line): mark = int(input("Mark? ")) / if mark >= 70: / [indent] print("Merit") / elif mark >= 40: / [indent] print("Pass") / else: / [indent] print("Keep practising"). Note: 70 gives Merit, 69 gives Pass, 40 gives Pass and 39 gives Keep practising. The tests include the boundary values.
3
A drawer search has six items: map, atlas, globe, compass, ruler, pencil. How many looks does a linear search need for (a) compass, (b) map, (c) eraser?
(a) 4 looks. (b) 1 look. (c) 6 looks, and the result is Not found.
4
Explain in two sentences the difference between a function and a procedure. Which one can be used inside a sum?
A function returns a value to the place where it was called, and a procedure does a job, such as printing, without returning a value. Only a function can be used inside a sum, such as double(3) + 1.
5
Write down the three kinds of error in a program (syntax, runtime, logic) and give one example of each from this term.
Syntax error: a missing colon after an if line. Runtime error: int("abc") or adding text to a number. Logic error: using < instead of <= so the boundary value is wrong. Any correct examples are fine.