| OCR |
GCSE (9-1) Computer Science
Mark Scheme
J277/02: Unit 2.2.10 Sub-programs
|
| Question | Answer | Marks | Guidance |
|---|---|---|---|
| 1 |
Gap 1: function OR def (1)Gap 2: return (1)
|
2 |
Accept either OCR Reference Language or Python keywords.
|
| 2 |
Function: Returns a value (1). Procedure: Does NOT return a value (just performs an action) (1). |
2 |
Must clearly distinguish based on the return value.
|
| 3 |
Output line 1: 50 (1)Output line 2: 10 (1)
|
2 |
Explanation (implied): Only the local variable changes inside the
function. Global remains 10.
|
| 4a | Line 02 | 1 | |
| 4b |
The parameter `user_input` is overwritten by a new input inside the function (1). This makes the passed argument useless/ignored (1). |
2 |
Focus on the overwriting of the parameter.
|
| 5 | 16 (3) | 3 |
Working:
c = 5 + 3 = 8 (1) Check 8 > 10 is False (1) Return 8 * 2 = 16 (1) |
| 6 |
function get_discount(price)
if price > 100 then
price = price * 0.9
endif
return price
endfunction
|
6 |
Mark Points:
- Correct function definition with parameter (1) - Correct IF condition (> 100) (1) - Correct calculation (* 0.9 or - 10%) (1) - Correct return of result (1) - Logic/Syntax correctness (2) |
| 7a | Use a Sub-program (Function/Procedure). | 1 | |
| 7b |
Any two from: - Code Reusability (1) - Easier Maintenance/Debugging (1) - Decomposability (breaking down problems) (1) |
2 | |
| 8 | Arguments | 1 |
Parameters are the variable names in definition; Arguments are the
values passed.
|