Good morning everyone!
Introduction to Variables
Today we are going to learn about a very important part of a computer program: variables.
- A number variable could hold numerical data such as the year, the temperature, or your age
- A string variable holds a string of alphanumeric characters such as a person’s name, a password, or the day of the week.
- A boolean variable has only two values: true or false. You might have certain things that happen only when the variable called gameOver is false, for example.
- A sprite is a special variable that represents a single dot on the screen and holds two separate values for the row and column the dot is currently in.
Activity 1 – Manual Score Keeping
Now we are going to play a few games of Rock, Paper, Scissors. Everyone should get into groups of 3 and have two players play the game and one should keep score. After a few rounds, swap who the score keeper is. Do this until everyone has had a turn at being the score keeper.
Now lets look at your score sheets. Can you identify what things on your sheet are constants and what are variables?
Activity 2 – Build Your Own Score Keeper
We can now begin to code using variables. The instructions for this are found here: Score Keeper game
Activity 3 – Build Your Own Rock, Paper, Scissors game
The tutorial to build your own Rock, Paper, Scissors game is here: Rock, Paper, Scissors Tutorial