Topics: Variables, Conditionals
Week 4 Overview
- Introduce the concept of variables
- Practice using variables in Scratch
- Ensure that students know when to use variables in their coding
Materials and Resources
- Materials needed: Envelopes, slips of paper for each student
- Week 4 Lesson Plan
- Week 4 Worksheet
- Week 4 Worksheet Solution
- Week 4 Presentation
Lesson Plan Overview
View our detailed lesson plan here.
- Introduction (10 min): Review loops and conditionals
- Unplugged Activity (10 min): Mad Libs activity!
- [Optional] Live Coding (5 min): Demonstrate variables in Scratch, use “ask” and “join” blocks
- Worksheet (30 min): Log into Scratch accounts and work on the worksheet
- Wrap up (5 min): See how variables fit with the maze activity
Part 1: Scratching an Itch!
Let’s have the Scratch Cat keep track of how many times we hover over him!
- First, set up the program so that it starts when we click the flag and runs forever. We should also set the variable to 0 at first. - Next, create a conditional that runs if the pointer is touching Scratch. - Finally, complete the conditional to make the variable increase, and then wait a second!
Here’s the Block Bank:
Part 2: Count Scratchula!
Scratch is already keeping track of how many times we touch him, but he should be able to tell us how many!
When we press the spacebar, Scratch should say “You touched me ___ times!” and then reset his count.
- Create a new conditional that runs if we press the spacebar! - When we do, Scratch should say how many times we touched him, and then reset the variable.
Here’s the Block Bank:
Part 3: A Visit to Dr. Scratch!
The Scratch cat is hungry! Eating cake makes him more powerful, but running into a pufferfish hurts him.
Let’s keep track of his health level!
- First, set up the program so that it starts when we click the flag and runs forever. We should also set Scratch’s health variable to 10, and make him draggable.
- Next, create two conditionals that run if Scratch runs into the cake or the pufferfish. - Finally, complete each conditional to make the variable increase or decrease.
- Add another conditional to have Scratch say “Power up!” if his health gets too low. He should then reset his health to 10.
Can you change your drawing so that it uses two loops?
How else can we use randomness to make your drawing even more unique?