Your First Program ▶
What You'll Learn
- What a program is and how it runs
- How to build a sequence of commands
- How changing values changes the result
What Is a Program?
A program is an algorithm written in a language a computer can understand and run. Every app, game, and website you have ever used was created by someone writing a program.
In this course your programs are lists of blocks — each block is one instruction. When you click ▶ Run, the computer reads your blocks from top to bottom and executes each one.
Programs always run in order — block 1, then block 2, then block 3. This is called sequential execution and it is the foundation of all programming.
Changing the Values
Notice that the Move Forward and Move Backward blocks have a number you can change. That number is how many steps the turtle travels.
- A small number (like 20) moves the turtle a short distance
- A large number (like 150) moves the turtle a long distance
Try different values and see how they change what happens. This is called experimenting — and it's exactly what real programmers do!
If the turtle walks off the edge of the canvas, it just keeps going — you can always click ↺ Reset Canvas to bring it back to the center. You can never break the program, so experiment freely!
Reading a Program
Look at the program below and try to predict what the turtle will do before you click Run:
- Move Forward 80
- Turn Right 90°
- Move Forward 80
Can you picture the path? The turtle moves right, turns to face down, then moves down — making an L shape. After you guess, build it in the widget and check!
Recreate the program above in the coding widget. Then try to modify it to make a backwards L, or a Z shape. Use 🗑 Clear to start over anytime.
1. In what order does a program run its blocks?
2. What happens when you increase the number in a Move Forward block?
3. You click Run and the turtle does something unexpected. What should you do?