I’ve been looking for more ways to incorporate coding into math, and this activity is perfect! The classroom teachers and math coach were thrilled to be able to incorporate coding while still staying on track with math. This can even be an ongoing project throughout the year  as students cover more math topics, they can create games to help each other review.
Lesson overview
I did this lesson with 5th graders, but it can be modified for students in lower or higher grades. This project lends itself well to differentiation. The code planner provides a scaffold for students who are new to Scratch and/or need extra guidance as they’re working. Advanced students can go beyond the code planner by adding animations, sound effects, additional sprites, scene changes, and more. You can even create games in subject other than math!
Coding Background
I designed this lesson as a loose follow up to my Choose Your Own Adventure in Scratch lesson. Students completed the Choose Your Own Adventure project in the previous school year, so they all had used Scratch at least once and were familiar with conditional statements (if/then/else). However, this is the only formal prior experience many of them had with Scratch and the math game is still pretty beginnerfriendly. In the lesson plan, I’ve included tips to modify this project for students who have no prior experience with Scratch.
Programming lesson
For the full lesson, see the lesson plan and accompanying slides.
Before we started coding, I did a lesson to review conditionals and introduce variables. If your students are not already familiar with conditionals, see the full lesson plan for modifications to include that.
After reviewing, we spent the majority of the coding lesson talking about variables. We started by defining variables and their uses in games (such as keeping track of the score) and then predicted how the set [score v] to ( )
and change [score v] by ( )
blocks would manipulate the value of the (score)
variable.
One students were comfortable with the blocks used to manipulate variables, we started to plan out the code necessary for the game. Students filled out a code planner so they’d have a blueprint to follow as they started to code their games.
Coding projects
Once we finished the planner, students used it as a checklist and got started in Scratch. I printed the planners in black and white, so I projected this slide with colored versions of the blocks to make it easier for students to find them in Scratch.
For this project, we spent about 15 minutes at the end of the programming lesson and another full 45 minute period coding. This gave most students a chance to get at least a few questions done in their games, although very few had a finished product. My hope is that students can revisit this throughout the year if they have a few minutes of free time to continue improving their games, adding more questions as they cover different topics.
Tips and tricks
 For coding projects, I tend get a lot of the same questions when students get started. I like to rely on student experts to manage the volume of questions we need to field and reduce the burden on coteachers who may be less comfortable using Scratch.
 If you’d like to customize the lesson materials with your own images of Scratch blocks, check out my Scratch Blocks Addon for Google Docs and Slides. You can use this to generate and insert Scratch blocks inside of Google Docs/Slides.
 There are two ways to save projects on Scratch:
 Local files: Students download the Scratch project onto their computers (or Google Drives if using Chromebooks) and reupload them the next time they want to work. This means they don’t need accounts on Scratch but makes sharing projects more difficult.
 Scratch accounts: Students sign into Scratch accounts and save their projects online. Sharing is easier this way, but students need Scratch accounts. To create a whole class worth of accounts (and bypass the need for student email addresses), see my post on setting up Scratch educator accounts.

Given the option, some students would spend days customizing their sprites. For this project, we gave them 2 minutes to choose sprites and backdrops in the beginning. We told them they had to live with the sprites asis until their games were coded. After that, they could go back and continue customizing or add other features.
 Some questions may need to accept multiple right answers (e.g. 1000 and 1,000). To allow more than one correct answer, you can use the
< > or < >
block to check for multiple conditions. The “then” part of the condition will run as long as AT LEAST one of the conditions in the “or” block is true.
You can place < <> or <> >
blocks inside of each other for more than two options:
This work is licensed under a Creative Commons AttributionShareAlike 4.0 International License.