How to use the
Learning Portal

Learning Portal

Our hands-on, comprehensive lesson plans span a range of levels. Browse our free STEM and coding learning resources.

Marty Image

1.12 – Introduction to Parameters

45 Minutes

Lesson Overview

Students have had a lot of practice building code to get Marty to carry out a specific task but how do we produce code blocks that can change Marty’s behaviours when we pass different values to them? In this lesson, we will introduce parameters which helps us to do exactly that. Combined with functions, students will be able to program a shape generator using a single function.

Key vocabulary:
    Parameter , Function , Changing behaviour , Values , Code blocks,

Content Sections

  • Learning Objectives
  • Extensions & Challenges
    • Additional Reading
    • 1.12 – Introduction to Parameters

      45 Minutes

      Lesson Overview

      Students have had a lot of practice building code to get Marty to carry out a specific task but how do we produce code blocks that can change Marty’s behaviours when we pass different values to them? In this lesson, we will introduce parameters which helps us to do exactly that. Combined with functions, students will be able to program a shape generator using a single function.

      Key vocabulary:
        Parameter , Function , Changing behaviour , Values , Code blocks,
      • Lessons 1.1-1.11
      • Laptop, PC or Tablet
        • Marty the Robot
        • Marty Workbook (Lesson 3)
        • Laptops/Computers/Tablets
        • Access to the Scratch editor
        • Tape or pen and paper

      Learning Objectives

      • Understand why we might want our program to produce different outputs based on the values we have
      • Describe what a parameter is and how we can use them
      • Explore how we can create a shape generator using parameters and functions and describe how it works

      1. Ask students how they think we could use the same code blocks to have different outputs or actions

      2. Give an example where we pass in a variable or value into a statement for Marty like walk forwards by x number of steps and ask if students think we could change the outcome of this statement by changing a value

      a. They should be able to note that they have done this before and that yes, we can change the number of steps that Marty has taken

      b. Highlight that the values we pass in are called parameters and we can use them to change the output of the code block by changing attributes of the action

      3. Show code blocks for two different shapes and ask students what similarities there are between the two

      4. Programming task working in small groups with a device and a Marty

      a. Create a new function that when called will program Marty to walk in a square (using tape or pen and paper to draw out the different shapes on the ground as a helper for students)

      b. Note down what values there are and what happens when we change them

      c. Now create a new function with these values as parameters

      d. How can we change these values to make Marty walk in a different shape that isn’t a square like a triangle or hexagon

      Extensions & Support

      • Students could extend their program by getting a sprite to ask what shape the user wants Marty to walk in, save the answer as a variable and check the answer against other strings like “square” or “triangle” using an if statement that will then call the function with appropriate parameters
      • Ask students whether there are any shapes that they think their function wouldn’t work for, what are they and why won’t it work?

      Additional Reading

      • Educator’s Guide
      • Introduction to Programming with Marty using Scratch