Day 12 - Parameters and Return Values

Day 12: Parameters and Return Values

Learning Objectives

Essential Questions

Materials Needed

Vocabulary

Procedure (50 minutes)

Opening (8 minutes)

  1. Review and Connection (3 minutes)

    • Review basic function concepts from previous lesson
    • Connect to today's focus on making functions more versatile with parameters and return values
  2. Warm-up Activity (5 minutes)

    • Present a simple function that performs a calculation with fixed values
    • Ask students how they might modify it to work with different values
    • Introduce the need for parameters and return values

Main Activities (32 minutes)

  1. Lecture: Function Parameters and Return Values (12 minutes)

    • Define parameters as input variables of a function
    • Explain the difference between parameters and arguments:
      • Parameters are variables in the function definition
      • Arguments are values passed when the function is called
    • Demonstrate the syntax for functions with parameters:
      • PROCEDURE name(parameter1, parameter2, ...)
    • Explain how parameters make functions more versatile and reusable
    • Introduce return values:
      • Purpose of returning results from functions
      • Syntax for returning values: RETURN(expression)
      • How return values are used in the calling code
      • Assigning return values to variables: result ← functionName(args)
    • Discuss the flow of execution with parameters and return values
    • Explain how parameters and return values create function interfaces
  2. Demo: Passing Arguments and Receiving Results (8 minutes)

    • Walk through examples of functions with parameters and return values
    • Demonstrate how to pass different arguments to the same function
    • Show how return values can be used in expressions or stored in variables
    • Illustrate the execution flow with parameter passing and value returning
    • Show examples of common function patterns:
      • Calculation functions that return results
      • Conversion functions
      • Validation functions that return Boolean values
      • Transformation functions that process input and return modified output
  3. Hands-on: Writing Functions with Parameters and Return Values (12 minutes)

    • Students work in the programming environment
    • Guide students through creating functions with parameters and return values
    • Have students implement functions for tasks like:
      • Mathematical operations with variable inputs
      • String processing functions
      • Validation functions that return true/false
      • Conversion functions between different units or formats
    • Encourage students to test their functions with various arguments

Closing (10 minutes)

  1. Activity: Creating a Function Library for Common Operations (5 minutes)

    • Students work in small groups to design a set of related functions
    • Each group focuses on a specific domain (math, string processing, etc.)
    • Groups define function signatures with parameters and return types
    • Share and discuss the function libraries
    • Highlight how well-designed functions create useful tools
  2. Exit Ticket and Preview (5 minutes)

    • Students develop functions that take parameters and return values
    • Preview that next class will focus on function design and documentation

Assessment

Differentiation

For Advanced Students

For Struggling Students

Homework/Extension

Teacher Notes