# Coding in the Classroom ┃Grade 5 – Addition Game – Teacher Guide

By: Lisa Anne Floyd and Steven Floyd

In this Teacher Guide and Student Activity, variables and conditional statements are introduced. The activity aligns nicely with grade 5 expectations in the Ontario Grades 1-8 Mathematics Curriculum, but would be a good introduction or review for grades 6-8, depending on students’ previous experience with coding.

We’ve shared a Teacher Guide below, as well as a Student Activity page that you can share directly with students. A page with solutions has also been provided. The student activity involves students creating two applications by following video tutorials and then trying some extension activities. One application is an Addition Program that incorporates variables and the second application is an Addition Game that incorporates variables and conditional statements.

Teacher Guide

In the Ontario Grades 1-8 Mathematics Curriculum, Conditional Statements are introduced in grade 5:

C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves conditional statements and other control structures

C3.2 read and alter existing code, including code that involves conditional statements and other control structures, and describe how changes to the code affect the outcomes

Conditional Statements allow for the computer to make decisions and help with automating applications. Conditional Statements (If… then… else statements) can also make coding more interesting, as programs can run differently depending on how the conditional statement is evaluated.

In order to use Conditional Statements to their full potential, it helps if students first have an understanding of how to incorporate variables into their programs.

Variables

Variables play an important role in coding, allowing programs to be flexible and when used in combination with conditional statements, can help students make powerful programs.

Variables are like containers – they hold information, and as the name suggests, this information may change throughout the program. In a basketball game for example, the points for each team can be stored in a variable that can be displayed on a scoreboard. In a video game, variables are used to keep track of users’ scores.

In mathematics, traditional use of variables such as x in: 3 + x = 9 aren’t always “personally relevant”, as Seymour Papert suggested. Seymour Paper inspired children to experience mathematics through coding over four decades ago!

In coding, we tend to use descriptive names rather than single letters to represent variables.

Here are the typical steps for using Variables in computer programming:

1 – Declare the variable: This means, we will create a variable and give the variable a name. In Scratch, we select Variables, Make a Variable to do this.

2 – Initialize the variable: This is when we give the variable an initial or “starting” value.

3 – Use the variable: When we make use of the variable in our program, we are using the variable. The value might change throughout the program.

Below is a screen shot of code for a simple Addition Program that incorporates variables. In the Student Activity, students will create this program by following a video tutorial, before trying the extension activities.

We see three variables are incorporated into this program: num1, num2 and sum.

The completed program can be found here:

https://scratch.mit.edu/projects/515553250/editor

The video tutorial which is shared in the Student Activity can be found here:

You’ll see some extensions suggested in the Student Activity page as well.

Conditional Statements

The second application introduced in the Student Activity, is a simple Addition Game that incorporates Conditional Statements.

The Ontario Ministry of Education defines a conditional statement as:

“A type of coding instruction used to compare values and express and make decisions. A conditional statement tells a program to execute an action depending on whether a condition is true or false. It is often represented as an if-then or if-then-else statement.”

In the Addition Game, two variables called num1 and num2 are given random values between 0 and 10. The + operator variable is used to add these two variables together and this value is stored in a variable called sum. The user will see the values of the num1 and num2 variables displayed on the stage when they click the green flag and will be asked to enter the sum of the two numbers.

A conditional statement is then used to determine if the user is correct or incorrect. The conditional statement compares the sum of the two numbers to the user’s answer.  You can see that we’ve written pseudocode for the conditional statement in our program:

Pseudocode is defined by the Ministry of Education as:

An informal way of describing a computer program or algorithm that is an intermediary between everyday language and programming code. Pseudocode is often used before actual coding to explain the design process in a less technical way.”

Below is a screen print of the Addition Game, written with Scratch code:

The completed program can be found here:

https://scratch.mit.edu/projects/515549785/editor/

The video tutorial which is shared in the Student Activity can be found here:

Here is the link to the Student Activity.

Solutions have also been provided. You may wish to share these with students if they are stuck.

Scroll to Top