Parameters and Return ValuesActivities & Teaching Strategies
Active learning works for parameters and return values because students need to see memory concepts in action, not just hear about them. Hands-on tracing and debugging let students observe how data moves and changes, building durable mental models beyond abstract explanations.
Learning Objectives
- 1Compare the effects of passing parameters by value versus by reference on a shared variable within a program.
- 2Construct a function that accepts multiple parameters and returns a calculated numerical result.
- 3Analyze how a function's return value can be used as an input for another function or a subsequent calculation.
- 4Design a simple program that decomposes a larger task into smaller subroutines, each utilizing parameters and return values.
Want a complete lesson plan with these objectives? Generate a Mission →
Pair Programming: Value vs Reference Duel
Pairs write two versions of a function: one modifying an integer by value and one by reference using addresses or objects. Call each with test data, print variables before and after, then swap and explain results. Extend to lists for visual changes.
Prepare & details
Explain the concept of passing parameters by value versus by reference.
Facilitation Tip: In Value vs Reference Duel, insist each pair prints both the memory address and the value before and after the call to make the abstraction concrete.
Setup: Groups at tables with problem materials
Materials: Problem packet, Role cards (facilitator, recorder, timekeeper, reporter), Problem-solving protocol sheet, Solution evaluation rubric
Small Group Challenge: Multi-Param Calculator
Groups design functions taking two numbers and an operator as parameters, compute results, and return the value. Integrate into a main program for a menu-driven calculator. Test edge cases like division by zero collaboratively.
Prepare & details
Analyze how return values enable functions to contribute to larger computations.
Facilitation Tip: For the Multi-Param Calculator, provide a starter sheet with partially written tests so groups focus on function logic rather than syntax scaffolding.
Setup: Groups at tables with problem materials
Materials: Problem packet, Role cards (facilitator, recorder, timekeeper, reporter), Problem-solving protocol sheet, Solution evaluation rubric
Whole Class Debug Relay: Parameter Pitfalls
Project buggy code on screen with mixed passing modes and return errors. Teams send one member at a time to fix one issue, relay back with explanation. Class votes on fixes and runs tests together.
Prepare & details
Construct a function that takes multiple parameters and returns a calculated result.
Facilitation Tip: During Parameter Pitfalls, give each team only two minutes per relay station so they practice rapid diagnosis and concise explanations under time pressure.
Setup: Groups at tables with problem materials
Materials: Problem packet, Role cards (facilitator, recorder, timekeeper, reporter), Problem-solving protocol sheet, Solution evaluation rubric
Individual Extension: Custom Function Portfolio
Students independently create three functions with parameters and returns for a personal project, like a grade calculator. Document inputs, outputs, and passing modes with traces. Peer review follows.
Prepare & details
Explain the concept of passing parameters by value versus by reference.
Facilitation Tip: In the Custom Function Portfolio, require students to include at least one example using pass by reference and one using multiple parameters to demonstrate mastery.
Setup: Groups at tables with problem materials
Materials: Problem packet, Role cards (facilitator, recorder, timekeeper, reporter), Problem-solving protocol sheet, Solution evaluation rubric
Teaching This Topic
Teach by making students confront the limits of their intuitions through guided tracing. Avoid long lectures on memory; instead, use live code projection where you step through calls and let students vote on outcomes. Research shows that concrete, observable differences—like address prints and value changes—build stronger understanding than abstract diagrams. Emphasize the difference between inputs (parameters) and outputs (returns) by isolating them in separate lines of code and naming conventions.
What to Expect
Successful learning looks like students correctly predicting subroutine behavior, distinguishing value and reference at a glance, and confidently integrating functions with multiple parameters into larger programs. By the end, they should explain their choices and debug related errors independently.
These activities are a starting point. A full mission is the experience.
- Complete facilitation script with teacher dialogue
- Printable student materials, ready for class
- Differentiation strategies for every learner
Watch Out for These Misconceptions
Common MisconceptionDuring Pair Programming: Value vs Reference Duel, watch for students assuming all parameters pass by value and therefore changes inside functions never affect caller variables.
What to Teach Instead
Have pairs add two print statements before and after the function call: one showing the memory address of the variable, the other showing its value. Ask them to compare addresses across calls to see when references are shared.
Common MisconceptionDuring Multi-Param Calculator, watch for students believing return values directly change the parameters passed in.
What to Teach Instead
Require students to write a short test case where they call the function, store the return value in a new variable, and then inspect both the parameter and the return variable separately to confirm no mutation occurred.
Common MisconceptionDuring Custom Function Portfolio, watch for students asserting that functions cannot produce multiple outputs beyond a single return value.
What to Teach Instead
Ask students to use the portfolio template to include a function that uses a reference parameter to return a second computed value, then document why this approach works and how it differs from returning multiple values directly.
Assessment Ideas
After Pair Programming: Value vs Reference Duel, present two short code snippets and ask students to predict the final printed values and explain the difference in their reasoning, using memory addresses as evidence.
After Multi-Param Calculator, collect each student’s completed ‘calculate_area’ function call and printed return value to verify correct parameter usage and return handling.
After Parameter Pitfalls, ask students to describe in pairs a function they might create for a library inventory system, naming parameters, return values, and whether they used pass by value or reference, then share one insight with the class.
Extensions & Scaffolding
- Challenge: Ask early finishers to write a function that returns multiple values using a tuple or dictionary, then integrate it into a larger program.
- Scaffolding: For struggling students, provide a partially filled function template with labeled parameters and a single return line to reduce cognitive load.
- Deeper exploration: Invite students to compare pass by value versus pass by reference in a language that defaults to one or the other, then discuss trade-offs in design and performance.
Key Vocabulary
| Parameter | A variable listed inside the parentheses in a function definition, acting as an input placeholder for data. |
| Argument | The actual value that is passed into a function when it is called, corresponding to a parameter. |
| Return Value | The data that a function sends back to the part of the program that called it after completing its task. |
| Pass by Value | A method of passing arguments where a copy of the argument's value is sent to the function; changes inside the function do not affect the original variable. |
| Pass by Reference | A method of passing arguments where the function receives a reference (memory address) to the original variable; changes inside the function directly affect the original variable. |
Suggested Methodologies
More in The Art of Programming
Sequence: The Order of Execution
Understanding that instructions are executed in a specific order.
2 methodologies
Selection: Conditional Logic (If/Else)
Implementing 'if', 'else if', and 'else' statements to control program flow.
2 methodologies
Selection: Case Statements
Using case statements (or switch statements) for multi-way branching.
2 methodologies
Iteration: Fixed Loops (For)
Using 'for' loops to repeat a block of code a predetermined number of times.
2 methodologies
Iteration: Conditional Loops (While)
Using 'while' loops to repeat a block of code until a condition is met.
2 methodologies
Ready to teach Parameters and Return Values?
Generate a full mission with everything you need
Generate a Mission