Sometimes recipes may say
' current height is 50
This means that there's some piece of information you need to remember. We need to create a made up name to represent this data. That made up name is called a 'variable'.
We take from the sentence ' current height is 50 ' and turn it into
' current height is 50
CurrentHeight = 50
Then we can use that made up name later in our recipe
' current height is 50
CurrentHeight = 50
'Move the tortoise up the amount of the current height
Tortoise.Move(CurrentHeight)
Notice we used that made up name 'CurrentHeight' in the recipe instructions for moving the tortoise
Sometimes you'll type the same thing over and over
Tortoise.SetPenColor("pink")
Tortoise.Move(5)
Tortoise.SetPenColor("blue")
Tortoise.Move(7)
Tortoise.SetPenColor("pink")
Tortoise.Move(10)
Tortoise.SetPenColor("blue")
Tortoise.Move(13)
Tortoise.SetPenColor("pink")
Tortoise.Move(15)
Tortoise.SetPenColor("blue")
Tortoise.Move(17)
Tortoise.SetPenColor("pink")
It would be nice to not to have continually type "pink" or "blue". Variables allow you to only have to type a value one time.
FirstColor = "pink"
SecondColor = "blue"
Tortoise.SetPenColor(FirstColor)
Tortoise.Move(5)
Tortoise.SetPenColor(SecondColor)
Tortoise.Move(7)
Tortoise.SetPenColor(FirstColor)
Tortoise.Move(10)
Tortoise.SetPenColor(SecondColor)
Tortoise.Move(13)
Tortoise.SetPenColor(FirstColor)
Tortoise.Move(15)
Tortoise.SetPenColor(SecondColor)
Tortoise.Move(17)
Tortoise.SetPenColor(FirstColor)
An added bonus is that now if you wanted to change the SecondColor to be "purple", you would only have to change it in one place.
FirstColor = "pink"
SecondColor = Colors.Purple