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

Pass by value and pass by reference storage modelsPass by valuecaller remaining8copylocal seats8 → 6caller remains 8 after the callPass by referencecaller remaining8 → 6parameterreferenceboth names reach the caller's storageExam chain: storage mechanism → internal change → caller-visible effectPython: distinguish mutation of a shared object from reassignment of a local name.

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.

Multiple choice1 mark

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 table3 marks

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.

AlgorithmExam reference language
  1. function reserve(seats)
  2. seats = seats - 2
  3. print(seats)
  4. return seats
  5. endfunction
  6. remaining = 8
  7. local_result = reserve(remaining)
  8. print(remaining)
Trace table with 5 columns
Rowremainingseats (reserve)local_resultReturn valueOutput
1
2
3
4
5
Written answer3 marks

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.

Written answer3 marks

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.

Written answer4 marks

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.

Written answer3 marks

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.

Multiple choice1 mark

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.

Fill in the blanks4 marks
Pass by value supplies a local checkpoint gap 1, so reassignment leaves the caller's original value checkpoint gap 2. Pass by reference gives access to the caller's checkpoint gap 3, so an assignment can be visible after the call. That visible change is a checkpoint gap 4.

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.