Community resourceWorksheet
1CP2-CT-7.2 Subprograms parameters return values and scope
Part 2 of 5 · 1CP2-CT-7 · Subprograms, scope and libraries
The subprogram worksheet, separating what a procedure does from what a function returns and keeping scope under control.
Students will:
- distinguish a procedure from a function that returns a value
- follow arguments, parameters and return values through nested calls
- explain why a local variable suits an intermediate calculation
- explain why a program should minimise global variables
- propose subprogram responsibilities that separate concerns
Inside: 7 explanation cells, 3 multiple-choice questions, 1 Python task, 1 fill-in-the-blanks cell and 3 written answers. 18 marks, about 45 minutes.
Series: 1CP2-CT-7 · Subprograms, scope and libraries, part 2 of 5.
Shared by Coding PathwayVerified teacher
- 15 cells
- About 45 minutes
- CC BY-SA 4.0
- Shared 17 Aug 2026
Preview
The whole resource, exactly as a class sees it. Answers and marking are held back.
Subprograms, parameters, return values and scope
A subprogram is a named, reusable section of code. A procedure performs an action; a function returns a value. Parameters receive values supplied by arguments in a call. Splitting a problem into subprograms supports decomposition and separation of concerns: each part has one clear responsibility.
1. Model procedure and function roles
def show_label(name):
print("Name: {}".format(name))
def rectangle_area(width, height):
return width * height
show_label("Mina")
area = rectangle_area(4, 3)
print(area)
show_label performs display as a procedure. rectangle_area supplies a result that the caller stores. name, width and height are parameters; the values in the calls are arguments.
- argument
- global
- parameter
- return value
2. Predict returned values
Read this code without running it.
def adjusted(score, bonus):
result = score + bonus
return result
first = adjusted(8, 2)
second = adjusted(first, 3)
print(second)
What exact value is printed?
- A10
- B11
- C13
- D23
Explain the flow of arguments, parameters and return values through both calls.
Use the values 8, 2, 10 and 3 in order.
Students type their answer here.
3. Keep scope controlled
A local variable is available only inside the subprogram where it is created. A global variable is declared in the main program and is available more widely. Local names reduce unintended interference and make a subprogram easier to test. Pearson expects global variables to be minimised. The Python global keyword is not part of the Programming Language Subset; pass required values as parameters and return results instead.
Why is a local variable often preferable for an intermediate calculation?
- AIt can never hold a number.
- BIt limits the name to the subprogram and reduces unintended changes elsewhere.
- CIt automatically prints the result.
- DIt is available before the function is called.
Explain why a program should minimise global variables.
Give a mechanism and consequence, not only 'they are bad'.
Students type their answer here.
4. Build a reusable function
Define delivery_cost(distance, rate) to return distance * rate. Call it with 12 and 1.5, store the returned value in cost, and print cost. Keep the intermediate result local to the function; do not use the global keyword.
# Define delivery_cost(distance, rate), call it and print the returned cost.
5. Separate concerns
A well-decomposed solution might use one function to calculate a value and a separate procedure to display it. This makes each part independently testable. A subprogram should not unexpectedly read or change unrelated global state when its required data can be supplied explicitly.
A program validates an age, calculates a ticket price and displays a receipt. Propose three subprogram responsibilities and explain one benefit of the separation.
Give one clear responsibility per subprogram.
Students type their answer here.
Which design has the clearest separation of concerns?
- AOne long block that inputs, calculates and prints repeatedly.
- BA calculation function that returns a price and a separate procedure that formats the receipt.
- CA function that changes many unrelated globals.
- DCopying the same calculation into every branch.
Route forward
You can distinguish procedures, functions, parameters, arguments, return values, local and global scope. Next you will use Pearson's permitted maths, time and formatting methods inside these structures.