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.8 – Introduction to Variables

45 Minutes

Lesson Overview

Variables will be introduced in this lesson as a way of storing and remembering values that can be used later in a program for decisions to be made. This will start off with a small programming challenge in Scratch that will be extended to include Marty.

Key vocabulary:
    Code blocks , Variables , Store , Values , Output,

Content Sections

  • Learning Objectives
  • Extensions & Challenges
  • Additional Reading
  • 1.8 – Introduction to Variables

    45 Minutes

    Lesson Overview

    Variables will be introduced in this lesson as a way of storing and remembering values that can be used later in a program for decisions to be made. This will start off with a small programming challenge in Scratch that will be extended to include Marty.

    Key vocabulary:
      Code blocks , Variables , Store , Values , Output,
    • Lessons 1.1-1.7
    • Laptop, PC or Tablet
      • Marty the Robot
      • Marty Workbook (Lesson 4)
      • Laptops/Computers/Tablets
      • Access to the Scratch editor

    Learning Objectives

    • Understand that variables are a way to store and remember a value for you
    • Understand when variables should be used
    • Create a program that makes use of a variable to change the output

    1. Discussion of when you are counting up something, how do you keep track of the total?

    2. Introducing variables as a way to keep track of this for us in our programs

    3. Show some example programs in the presentation and discuss what students think the printed message will be based on what the variable is holding

    4. Programming task where students need to program a sprite in Scratch to say what the number is that is being held in the variable and add one to that value (a counting program)

    5. Highlight that it isn’t just numbers that we can put into variables but also text too

    a. Ask students to store their name in a variable by using the ask block as a way to get input from the user

    b. Then include that variable in the Hello message to the user before asking them to click the sprite the number of times to represent the number of steps they want Marty to take

    c. Students should then use the count variable to be the number of steps that Marty should take

    Extensions & Support

    Students should explore what other Marty blocks they can use their variable values for (for example, taking in the angle of the mouse pointer to decide which way Marty should turn)

    Additional Reading

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