All Resources

Input and Interaction

This activity introduces the idea of variables as well as the ability to have a program ask the user for input.

Using variables requires a bit more abstract thinking than the previous activities, so be prepared to spend extra time especially with younger students.

Objectives

  • Introduces the idea of variables.

Materials

  • Per Student:
    computer per two students (one computer per student is better)

  • Per Class:
    computer with projector or SMART board.

Key Questions

  • Does the program in student step 1 know whether you type your name or a nonsense word? (No! It takes whatever you give it and counts the letters, even if the letters are numbers.)What happens in student step 2 if you type letters instead of numbers? (The program behaves as though the number you gave it were zero.)

What To Do

Preparation:

Ensure that all the computers work, and are connected to the internet.
Set up the instructor computer and projector or SMART board.  Log in to the Scratch website.

Acitvity:

Instructor:

  1. Explain that you are going to make it possible to enter information during a program.
  2. On the screen or SMART Board, open a new Scratch project and select the Sensing tab.
  3. Point out the “ask_and wait” block and the “answer” block.  Explain that “answer” is a variable (its value can change, depending on what the user types in when the question is asked).
  4. Have students follow along on their own computers as you build this logic:

  1. Run the program.  Run it again with a different answer.
  2. Point out that you can use a variable anywhere you usually put a number or words.

Students:

  1. Use the “length of _” operator block to write a program where the sprite tells you how many letters are in your name.
  2. Use the “move_steps” block and a forever block to write a program where you can tell the sprite how far to move.

Extensions

Other Resources

Liked this activity? Learn more about effective programming communication in collaboration with our friends from IBM.

 

About the sticker

Survivors

Artist: Jeff Kulak

Jeff is a senior graphic designer at Science World. His illustration work has been published in the Walrus, The National Post, Reader’s Digest and Chickadee Magazine. He loves to make music, ride bikes, and spend time in the forest.

About the sticker

Egg BB

Artist: Jeff Kulak

Jeff is a senior graphic designer at Science World. His illustration work has been published in the Walrus, The National Post, Reader’s Digest and Chickadee Magazine. He loves to make music, ride bikes, and spend time in the forest.

About the sticker

Comet Crisp

Artist: Jeff Kulak

Jeff is a senior graphic designer at Science World. His illustration work has been published in the Walrus, The National Post, Reader’s Digest and Chickadee Magazine. He loves to make music, ride bikes, and spend time in the forest.

About the sticker

T-Rex and Baby

Artist: Michelle Yong

Michelle is a designer with a focus on creating joyful digital experiences! She enjoys exploring the potential forms that an idea can express itself in and helping then take shape.

About the sticker

Buddy the T-Rex

Artist: Michelle Yong

Michelle is a designer with a focus on creating joyful digital experiences! She enjoys exploring the potential forms that an idea can express itself in and helping then take shape.

About the sticker

Geodessy

Artist: Michelle Yong

Michelle is a designer with a focus on creating joyful digital experiences! She enjoys exploring the potential forms that an idea can express itself in and helping then take shape.

About the sticker

Science Buddies

Artist: Ty Dale

From Canada, Ty was born in Vancouver, British Columbia in 1993. From his chaotic workspace he draws in several different illustrative styles with thick outlines, bold colours and quirky-child like drawings. Ty distils the world around him into its basic geometry, prompting us to look at the mundane in a different way.

About the sticker

Western Dinosaur

Artist: Ty Dale

From Canada, Ty was born in Vancouver, British Columbia in 1993. From his chaotic workspace he draws in several different illustrative styles with thick outlines, bold colours and quirky-child like drawings. Ty distils the world around him into its basic geometry, prompting us to look at the mundane in a different way.

About the sticker

Time-Travel T-Rex

Artist: Ty Dale

From Canada, Ty was born in Vancouver, British Columbia in 1993. From his chaotic workspace he draws in several different illustrative styles with thick outlines, bold colours and quirky-child like drawings. Ty distils the world around him into its basic geometry, prompting us to look at the mundane in a different way.