Surprise! You just wrote your first computer program! A program is just a collection of instructions that a computer can run. When you combined the existing commands to go BACKWARDS, you wrote a program.
Now that you’ve gotten command of commands, let’s turn our attention to another aspect of programming: variables.
Our favorite turtle is back on the board! You’ve got all the same buttons at your disposal, but you’ve got some interesting monitors down at the bottom of the screen. You should see three different displays:
- POSITION (where am i?)
- HEADING (what direction am i facing?)
- WHAT_IS_AHEAD (what is ahead of me?)
Each of these monitors shows the current value of a variable for your turtle-buddy. Just like an object in the real world has properties (e.g. color, texture, hardness, etc.), computational objects have these properties too!
Variables are very important to understand because they can have an effect on the outcome of commands. For instance, does the FORWARD button always do the same thing? Or does it depend on what the value of HEADING is for the turtle?
You can think of a variable as a named container that stores a piece of data for us to use later.
Move your turtle around and watch how the value in each of these three different properties changes as you move.