Variables: how to explain them
Variables have a value which the creator can assign, meaning they can vary from program to program depending on what is needed.
That make sense?
When I first taught variables to students I started with the very concept of something which varies.
I gave them a colour in picture and using their own pens/pencils told them to colour in the costume on the character.
We then hung the finished pictures on the wall and I asked the class how much could see in the colours of the characters outfits.
The answer was lots! So we discussed all the colours we could see, why we’d all done a different colour and how this displayed variables. The variable was the colour of the jacket.
In pseudo code it might look like this:
- JacketColour = Green
- JacketColour = Blue
So the variable is JacketColour because it can vary (ie change) depending on the options available (which colours are in the pot or pencil case).