In this lesson students spend most of their time practicing using the skills and processes they have learned about variables. At the conclusion of the lesson students discuss the main things they realized and still have questions about at the conclusion of this lesson.


Students will be able to:


This lesson is students primary opportunity to get hands on with variables in code prior to the Make activity in the following lesson. Give students as much class time as you can to work through these. For this lesson it's recommended that you place students in pairs as a support and to encourage discussion about the challenges or concepts they're seeing. In the following lesson students are encouraged to work independently.


Getting Started


Teaching Tip

Move Quickly to the Activity: There's a lot in the main activity of today's lesson. You may optionally wish to do a quick vocabulary review or address any questions that came up in the last lesson. Otherwise, give students more time to get hands on with some code.

This is the first official "Practice" lesson in the EIPM model. Review the EIPM model in theEIPM: A Short Introduction (Teacher Resource).

Practice Lessons:

Overview: Students practice using the new concept through a scaffolded series of programming activities.

Goal: Students gain confidence in writing and debugging programs that use the new concept.

A sketch showing students working together on computers.

Watch the following videos:


Group: It is recommended that students work in pairs for this lesson and a number of the activities feature discussion prompts. Consider using pair programming, having drivers and navigators switch every 3 minutes, not every project.

Distribute: Optionally pass out a plastic cup or other manipulative they can place on their computer when they are stuck as a signal that they need support.


Open a Project: Students will use a number of projects for this lesson, beginning with Lesson3_App1. Each project has instructions in a comment that describes what students should do for that project. When they finish one project, they can proceed to the next one.

Teaching Tip: Circulate around the room through the lesson encouraging students to use the strategies introduced in the previous lessons. Students have a number of supports at their fingertips, so a big part of your role is helping build their independence in using those resources.

Projects 1-2 Assigning Numbers and Strings: These projects only use the output commands which prints text in the console. Some key points in these levels:

Projects 3-7 Variables and Operators: These projects have students practice writing more complex expressions and using operators. A few tricky things to look out for

Regroup: Bring the class back together to watch the Scope Practice Video.

Teaching Tip: The concept of variable scope can be difficult for students to understand. It is highly recommended that you watch the video prior to the lesson. Slides are available for this lesson if you would like to optionally review as a class.

Display: Show the Scope Practice video.

Do This: Discuss these differences between global and local scope, and debugging tips for dealing with them.

Create Variables Once At the Top of Your Code

When you create variables you should:

Global vs. Local Variables

There's two types of variables, global and local, and so far we've only focused on global variables. Here's the main difference between global and local variables.

Avoiding Local Variables and Debugging

Local variables will eventually be useful but for now they're most likely to just be confusing. The biggest issue you'll run into right now with local variables is accidentally creating a variable in an action while trying to use a global variable. Here's what the code usually looks like:

integer count = 0
action ButtonActivated(Button button)
    integer count = count + 1

This code is pretty confusing. While it looks like there's only one variable being used, it actually has two variables, one local, and one global, and they're both named count! Changing the value of one will have no impact on the other. This can cause unexpected behavior in your code and it can get tricky to debug.

The best way to avoid these issues is to make sure for now that you're not using variable creation commands inside of an action. If you run into a tricky debugging problem, check if you're accidentally creating a local variable.

Resume the Activity

Project 8 Debugging Scope Issues: This project highlights a common bug that can come up when working with variables. While students should be aware of this bug, they don't quite have the background they'd need to fully understand it. For now support students in following the three main takeaways.

Project 9 Putting It All Together: This project asks students to put together many of the concepts they've seen so far. This is an opportunity to have a bit more of a "blank screen moment" while still being able to use some starter code as a guide.

Wrap Up

Prompt: What aspects of working with variables do you feel like clicked today? What do you still feel like you have trouble with?

Discuss: Have students share with one another before sharing with the whole class.

Discussion Goal: Use this opportunity to address any lingering questions or misconceptions in the room. You can also use this as a source of discussion topics to kick off the following lesson. As you lead the discussion, call out the many resources students have access to help when they're getting stuck.


Assessment: Check for Understanding: AP Practice

Question: What will be displayed after this code segment is run?

myPoints <- 2
myPoints <- 5
myPoints <- myPoints + 1
DISPLAY myPoints

Standards Alignment