Community resourceWorksheet
OCR H446 2.2.1 Passing parameters by value and reference
Part 7 of 14 · H446 2.2.1 · Programming techniques
Whether a change survives a call depends on the parameter mode, and H446 2.2.1 examines that distinction directly. Two storage models are set side by side in this worksheet, a copy for pass by value and shared access for pass by reference, then applied to OCR exam reference language headers and to Python's own behaviour.
Students will:
- model caller and callee storage separately for a single call
- trace a procedure whose scalar parameter is passed by value
- explain how the same procedure behaves differently under pass by reference
- write an OCR exam reference language header that mixes both parameter modes
- recommend a parameter mode for a shared variable and state a risk it introduces
Inside: 5 explanation cells, 2 multiple-choice questions, 1 fill-in-the-blanks cell, 4 written answers and 1 trace table. 19 marks, about 25 to 35 minutes.
Series: H446 2.2.1 · Programming techniques, part 7 of 14.
Shared by Coding PathwayVerified teacher
- 13 cells
- About 30 minutes
- CC BY-SA 4.0
- Shared 31 Aug 2026
- Updated 3 Sept 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Passing parameters by value and reference
A booking procedure may work on a copy or gain access to caller storage. The mechanism determines whether changes remain visible.
By the end, you will be able to
- trace caller and callee storage separately
- explain copy semantics for pass by value
- explain visible side effects for pass by reference
- avoid describing Python as simply either OCR model
Reactivate: local/global scope and subprogram interfaces.
The two storage models
By value: the subprogram receives a copy. Reassigning the parameter changes the local copy, not the caller's variable. That parameter is unavailable after the call finishes.
By reference: the parameter gives access to the caller's storage, often described in OCR mark schemes as passing its memory address. A change through that reference can therefore be visible to the caller, creating an intentional or accidental side effect.
A complete examination explanation names the mechanism and its scope: saying only ‘by value cannot change’ is inaccurate because the local copy can change.
Worked storage model
By value:
caller remaining: 8 → local seats copy: 8 → 6
after return, caller remaining is still 8
By reference:
caller remaining: 8 ← procedure accesses same storage → 6
after return, caller remaining is 6
Draw two boxes for by value and one shared box for by reference. Python passes object references: rebinding a local name and mutating a shared mutable object have different effects, so neither simple label is sufficient.
After a pass-by-value procedure changes its scalar parameter, what happens to the caller's original variable?
- AIt remains unchanged.
- BIt always changes to match.
- CIt is deleted.
- DIt becomes a global variable.
Trace this OCR ERL listing. Treat its scalar parameter as passed by value.
Enter a value only when it changes. Keep the listing's order.
Use one row for each pass through the loop. Fill in a box only when that value changes on that row, and leave the rest blank.
function reserve(seats)seats = seats - 2print(seats)return seatsendfunctionremaining = 8local_result = reserve(remaining)print(remaining)
| Row | remaining | seats (reserve) | local_result | Return value | Output |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 |
Explain the trace using the copy, the change inside the procedure and the original variable after the call.
Cover the mechanism as well as the final values.
Students type their answer here.
Under pass-by-reference semantics, the same procedure receives access to remaining instead. State both outputs and explain why they differ from pass by value.
Follow the assignment through the referenced storage.
Students type their answer here.
Write an OCR ERL procedure header named reserve that receives seats by reference and amount by value. In its body, subtract amount from seats. Then explain which caller variable may change.
Use OCR's explicit `name:byRef` and `name:byVal` notation.
Students type their answer here.
A procedure must update a shared remaining-seat variable and the caller must see the change. Recommend a parameter mode, then give one risk the programmer should manage.
Give a choice, scenario link and side-effect risk.
Students type their answer here.
Which statement about Python is the safest bridge to OCR's model?
- APython scalars are always passed by reference.
- BPython passes object references, so mutation and reassignment must be distinguished.
- CPython lists are always passed by value.
- DPython has no parameters.
Checkpoint
Complete the parameter-model distinction from memory. There is no answer bank, and correctness is withheld until teacher review.
Review your understanding
Before submitting, check that you can explain the main distinction in your own words, apply it in an unfamiliar context and justify the resulting behaviour or consequence.