5th Grade Variables with Scratch

Fifth graders at Laburnum Elementary have been learning about variables in Math (SOL5.19). Today, students in Ms. Hall’s class used variables and code to create mini math games using Scratch. I started out explaining the idea behind the math game: a character would ask for the players’ name, it would calculate the number of letters in the name, then create a multiplication problem with that number and a random number between 1 and 12. The player would try to solve the problem, and the character would let them know if they were right or wrong. Students could use their own creativity to modify the game however they wished. First, we selected a background and a character (called a sprite) in Scratch. Then, we went into the sprite’s costumes and used the paint tools to make a happy costume for the correct answer and a sad costume for the wrong answer. Now it was time to build the code with variables. I pointed out that a variable is just something that can change. So the player’s name is a variable, the number of letters in the name is a variable, the random number is a variable, and the player’s answer to the multiplication problem is a variable. In Scratch, you define variables using a piece of code that basically says, “Set (variable) to (whatever you define it as).” The variables are displayed in the top corner of the game to keep track of them, but you can delete those if you want. After defining the variables, the students added some “if-then-else” code so that if the answer is correct it would display the happy costume, otherwise it would display the sad costume. The character could also make a statement, if they wished. Finally, we shared our links on Schoology and tested each others’ games. You can see all their Scratch creations here (just click on their names under each picture). Be sure to click the “See Inside” button to view their code.