Skip to content
Computer Science · Grade 9

Active learning ideas

Function Parameters and Return Values

Active learning works for this topic because functions with parameters and return values are abstract concepts that become concrete when students build and test them themselves. Hands-on activities let students see how changing inputs affects outputs, making the connection between local scopes and reusable code clear.

Ontario Curriculum ExpectationsCS.HS.AP.8CS.HS.CT.9
20–40 minPairs → Whole Class4 activities

Activity 01

Problem-Based Learning30 min · Pairs

Pair Programming: Math Function Builder

Pairs define three functions: one for addition (two params), one for area (length, width), and one for volume (length, width, height), each returning a value. They test by calling functions in a main script and print results. Pairs swap scripts to verify outputs match expected values.

Analyze how parameters enable functions to be more versatile and reusable.

Facilitation TipDuring the Pair Programming activity, circulate and ask one partner to explain the parameter’s role while the other traces the function’s execution step-by-step using print statements.

What to look forProvide students with a Python code snippet containing a function definition with parameters and a function call. Ask them to identify the parameters, the arguments passed, and the expected return value. For example: 'In the function `calculate_area(width, height)`, what are the parameters? If called as `calculate_area(5, 10)`, what are the arguments? What value will this function return?'

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 02

Problem-Based Learning40 min · Small Groups

Small Groups: Function Chain Relay

Groups create a chain of three functions where the return value of the first feeds as a parameter into the second, and so on, to compute a final result like compound interest. Each member codes one function. Groups run the chain and adjust for accuracy.

Construct a function that takes multiple parameters and returns a computed value.

Facilitation TipFor the Function Chain Relay, set a visible timer so groups focus on breaking tasks into small, testable functions with clear parameters and returns.

What to look forGive students a scenario: 'You need a function to convert Celsius to Fahrenheit.' Ask them to write the function signature (including parameters) and one line of code showing how they would call it with a specific temperature, and what the expected return value would be. For example: 'Write a function `celsius_to_fahrenheit(celsius_temp)`. Show how to call it with 25 degrees Celsius and state the expected return value.'

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 03

Problem-Based Learning25 min · Whole Class

Whole Class: Parameter Puzzle Share-Out

Students write a function with three parameters on paper or whiteboard, solving a shared problem like grading averages. Post solutions around the room. Class walks through, identifies parameter uses, and votes on most reusable designs.

Differentiate between functions that perform an action and those that return a value.

Facilitation TipIn the Parameter Puzzle Share-Out, select groups to present their debugging process first, highlighting how they identified misplaced or missing parameters.

What to look forPose the question: 'When might you choose to write a function that simply prints a message versus a function that returns a calculated value? Provide a specific programming example for each case.' Facilitate a brief class discussion where students share their examples and reasoning.

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 04

Problem-Based Learning20 min · Individual

Individual: Refactor Challenge

Provide code with repeated calculations. Students identify patterns, rewrite as functions with parameters and returns, then compare original and new run times or outputs. Submit before-and-after code.

Analyze how parameters enable functions to be more versatile and reusable.

Facilitation TipRequire students to write a one-sentence comment above each function during the Refactor Challenge to explain what it returns and why that matters.

What to look forProvide students with a Python code snippet containing a function definition with parameters and a function call. Ask them to identify the parameters, the arguments passed, and the expected return value. For example: 'In the function `calculate_area(width, height)`, what are the parameters? If called as `calculate_area(5, 10)`, what are the arguments? What value will this function return?'

AnalyzeEvaluateCreateDecision-MakingSelf-ManagementRelationship Skills
Generate Complete Lesson

A few notes on teaching this unit

Start by modeling a simple function with parameters and return, then immediately have students predict outputs before running the code. Avoid front-loading terminology; instead, let students experience the need for parameters and returns through broken examples they fix together. Research shows students grasp scope better when they physically trace variables during debugging, so always include print statements in early examples.

Successful learning looks like students correctly defining functions with parameters, passing arguments without confusion, and using return values in subsequent code. They should articulate why parameters isolate changes and how return values enable chaining or reuse, demonstrating both procedural and functional thinking.


Watch Out for These Misconceptions

  • During the Pair Programming activity, watch for students who change a variable inside the function and assume it affects the same variable outside the function.

    Have partners add print statements before and after the function call to observe the unchanged caller variable, then discuss how parameters create isolated scopes that protect outer variables from accidental changes.

  • During the Function Chain Relay, watch for students who assume all functions must return a value to be useful.

    Direct groups to include both a procedure that prints a message and a function that returns a value in their relay. After testing, ask them to explain why one discards its result while the other enables further use.

  • During the Parameter Puzzle Share-Out, watch for students who believe return statements can only appear at the end of a function.

    Ask the presenting group to simulate early exit paths by commenting out sections and rerunning, then explain how returns work like exits in a maze, letting the function finish early when a condition is met.


Methods used in this brief