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.11 – Introduction to Functions

45 Minutes

Lesson Overview

In this lesson, we will introduce functions, another way to reduce the amount of repeated code and helps to break down tasks by creating small methods who are responsible for doing one or two things only. This will be introduced by getting students to think about tasks they do every day that could be defined as a function before breaking down a new program to include functions.

Key vocabulary:
    Functions , Repeat , Control , Method, Dance routine , Breakdown,

Content Sections

  • Learning Objectives
  • Extensions & Challenges
    • Additional Reading
    • 1.11 – Introduction to Functions

      45 Minutes

      Lesson Overview

      In this lesson, we will introduce functions, another way to reduce the amount of repeated code and helps to break down tasks by creating small methods who are responsible for doing one or two things only. This will be introduced by getting students to think about tasks they do every day that could be defined as a function before breaking down a new program to include functions.

      Key vocabulary:
        Functions , Repeat , Control , Method, Dance routine , Breakdown,
      • Lessons 1.1-1.10
      • Laptop, PC or Tablet
        • Marty the Robot
        • Marty Workbook (Lesson 2)
        • Laptops/Computers/Tablets
        • Access to the Scratch editor

      Learning Objectives

      • Understand what we use functions for and when to use them
      • Implement a function using Scratch either on a new program or altering an existing program
      • Describe how to break down a task into smaller manageable steps

      1. Introduction to functions as a way to breakdown a task and focus on a specific bit of functionality or sub-task. Relate this back to a textbook being divided into chapters where each chapter and sub-section of that chapter will focus on something specific

      2. Ask students to think about their morning routine – what do they do each morning? How could we break this up into a function? For example, things like brushing our teeth, getting dressed – these are all things that we can do without thinking in too much detail like brush up and down

      3. Note that functions are also a way to reduce the amount of duplicated code that we create, using example of a song where we break each section up into verse or chorus

      4. Programming task where students are asked to think about the dance routine that they programmed for Marty, but this time ask students to create functions of different dance moves and then call these functions in different sequences to change the dance routine easily and repeat things without reusing all of the individual movement blocks

      Extensions & Support

      • Ask students to go back through some different programs like the remote control and see how they would change that to make use of functions

      Additional Reading

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