Offline Coding Activities You Can Do with Your Students – Variables

Are you looking for a fun, free coding activity that you can do with your class? CodeMonkey has you covered in our newest blog column – Offline Coding Activities. You don’t need any coding experience to carry-out this activity – simply read the following exercise and then do it tomorrow in class! This week’s 20 minute-long activity will help students understand how variables work in programming.

Begin by asking for two student volunteers – Student 1 (who will act as the instruction given) and

Student 2 (who will act as the variable). You, the teacher, will act as the programmer. Student 1 will be in charge of the instruction to ‘step’ the distance of the given variable and Student 2 will be given a folded paper with the value of the variable.

Let your class know that Student 1 is representing the instruction part of the code. She knows that her instruction is to ‘step’. However, she does not know the distance she needs to step. Then, tell the class that you are handing Student 2 a folded piece of paper with a number between one and 10 on it. This paper will say how many steps Student 1 will need to take.

Instruct Student 2 to give the paper to Student 1 when you say start.

Explain to the class what is going to happen: First, Student 2 will give the note to Student 1. Then, Student 1 is going to step the number of steps written on the paper. Emphasize the fact that Student 1 only knows her instruction is to step, but she does not know how far yet. Now, instruct them to start.

After they are done, ask your class, “What do they think was the meaning of this activity?” Discuss the fact that when the instructions were given to Student 1, the number of steps was unknown to her, but it was still possible to give her the instructions. That is just how a variable works in computer programming.

Repeat the previous activity with 2 other students, but with the following difference:

This time Student 2 will write the number on the paper. Point out the fact that even though you, the programmer, does not know the number of steps Student 1 will need to take, you are still able to give the instructions. This is all an analogy for a variable – a programmer can give out commands or instructions without writing an exact value. They simply do this by using variables.

A variable in programming is like a storage unit; we store data in it, and we use it only when we need it. It is similar to the piece of paper we had in the activity, in that it can hold a value for later use. This activity is intended to represent how variables work in programming. In this example, student 1 knew the action she needed to carry out, but she didn’t have the variable until student 2 gave her the paper.

These offline activities are from our lesson plans. For more fun activities and a detailed curriculum guide on how to teach CodeMonkey, sign-up for our free teacher trial here.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.