Skip to content
Computer Science · 9th Grade

Active learning ideas

Introduction to Functions

Functions help students move from writing linear scripts to designing systems where code is organized, reusable, and easier to debug. Active learning works for this topic because students see firsthand how breaking tasks into functions improves clarity and reduces repetition.

Common Core State StandardsCSTA: 3A-AP-17CSTA: 3A-AP-18
25–40 minPairs → Whole Class4 activities

Activity 01

Think-Pair-Share25 min · Pairs

Think-Pair-Share: Function Identification

Present a 40-line program written without functions. Students individually identify at least three sections they would extract into named functions and choose a name for each. Pairs compare their choices and discuss where their extractions differ. The class builds a consensus version on the board.

Explain the benefits of using functions to organize code.

Facilitation TipDuring Think-Pair-Share: Function Identification, circulate and listen for students to articulate how a function’s name and purpose connect to its role in the program.

What to look forPresent students with a short Python script that repeats a block of code multiple times. Ask them to identify the repeated block and then write a new function that encapsulates this block, demonstrating how to call it in place of the original repetitions.

UnderstandApplyAnalyzeSelf-AwarenessRelationship Skills
Generate Complete Lesson

Activity 02

Jigsaw40 min · Small Groups

Collaborative Refactoring: From Script to Functions

Groups receive a working but repetitive script. Their task is to refactor it using functions without changing its output. Groups present their refactored version and explain each design choice. The class discusses which grouping strategies produced the clearest code.

Construct a simple function that performs a specific task.

Facilitation TipIn Collaborative Refactoring: From Script to Functions, emphasize naming conventions by asking students to defend their chosen function names during group discussions.

What to look forProvide students with a function definition that includes parameters. Ask them to write a line of code that calls this function, passing in appropriate arguments, and then write one sentence explaining the difference between the parameter and the argument they used.

UnderstandAnalyzeEvaluateRelationship SkillsSelf-Management
Generate Complete Lesson

Activity 03

Peer Teaching30 min · Pairs

Peer Teaching: Function Explanation Challenge

One partner writes a function and then explains it to their partner using only plain English, no code or technical jargon. The listening partner codes what they hear described. They compare the coded result to the original and discuss any gaps in the explanation.

Differentiate between parameters and arguments in function calls.

Facilitation TipFor Peer Teaching: Function Explanation Challenge, provide sentence stems like 'This function does ____ by ____' to scaffold explanations.

What to look forStudents write a simple function to solve a small problem (e.g., calculate the area of a rectangle). They then exchange their functions with a partner. Each partner reviews the code for clarity, correctness, and proper use of parameters/arguments, providing one specific suggestion for improvement.

UnderstandApplyAnalyzeCreateSelf-ManagementRelationship Skills
Generate Complete Lesson

Activity 04

Gallery Walk25 min · Small Groups

Gallery Walk: Function Anatomy

Post six function examples with different structures (no parameters, multiple parameters, return value, no return value, calling another function, modifying a list). Students annotate each with what the function does, what goes in, and what comes out.

Explain the benefits of using functions to organize code.

Facilitation TipDuring Gallery Walk: Function Anatomy, assign roles so some students focus on tracing execution while others analyze parameter usage.

What to look forPresent students with a short Python script that repeats a block of code multiple times. Ask them to identify the repeated block and then write a new function that encapsulates this block, demonstrating how to call it in place of the original repetitions.

UnderstandApplyAnalyzeCreateRelationship SkillsSocial Awareness
Generate Complete Lesson

A few notes on teaching this unit

Teachers should introduce functions as tools for abstraction, not just repetition. Avoid teaching functions in isolation; instead, connect them to real-world systems like vending machines or traffic lights. Research suggests students grasp functions best when they first experience the pain of repeated code, then see functions as the solution. Emphasize naming and purpose early, as these habits prevent later confusion.

By the end of these activities, students will define functions with parameters, call them correctly, and explain why functions make code more maintainable. They will also evaluate peers' functions for readability and correctness.


Watch Out for These Misconceptions

  • During Think-Pair-Share: Function Identification, watch for students who claim functions are only useful when code repeats.

    Use the activity to highlight how function names like validate_user_age() improve readability even if the code runs once. Ask students to compare scripts with and without functions to see the difference in clarity.

  • During Collaborative Refactoring: From Script to Functions, watch for students who think defining a function runs the code immediately.

    During the activity, have students annotate their scripts to mark when the function is defined versus when it is called. Ask them to trace execution step-by-step in pairs.

  • During Peer Teaching: Function Explanation Challenge, watch for students who confuse functions with methods.

    Use this activity to clarify that methods are functions tied to objects. Ask students to identify which functions in their examples could be methods if they belonged to a class.


Methods used in this brief