What Is an Algorithm? 🧩
What You'll Learn
- What an algorithm is and why it matters
- How computers follow step-by-step instructions
- How to control the turtle with your first commands
Step-by-Step Instructions
An algorithm is a set of step-by-step instructions that solves a problem or completes a task. You use algorithms every day without knowing it!
Think about tying your shoes:
- Cross the laces
- Pull one under the other and tighten
- Make a loop with one lace
- Wrap the other around it
- Pull through and tighten
If you did step 3 before step 2, it wouldn't work. Order matters!
The word "algorithm" is over 1,000 years old. It comes from Al-Khwarizmi, a Persian mathematician whose books on math changed the world.
Computers Need Exact Instructions
Computers are incredibly fast — but they are not smart on their own. They do exactly what they are told, nothing more and nothing less.
If you tell the turtle to move forward 60 steps, it moves exactly 60 steps. If you forget to tell it to turn, it will never turn — even if turning would make more sense to you!
Clear, correct instructions are the most important skill in coding.
If you were a robot told to "make a sandwich," what questions would you need answered first? Where is the bread? What goes on it? Computers need that same level of detail.
Meet the Turtle 🐢
In this course you will give instructions to a turtle — a glowing triangle that moves around a canvas on your screen. The turtle understands these commands:
- ⬆ Move Forward — turtle travels forward by a number of steps you choose
- ⬇ Move Backward — turtle travels backward
- ↰ Turn Left 90° — turtle rotates a quarter-turn to the left
- ↱ Turn Right 90° — turtle rotates a quarter-turn to the right
The turtle starts in the center of the canvas, facing right. Add blocks to the program, then click Run to watch it go!
Click the blocks on the left to add them to your program. Then press ▶ Run to watch the turtle execute your algorithm step by step.
Try to move the turtle to the right edge of the canvas. The canvas is 320 units wide — the turtle starts at the center (160 units in). How far does it need to go?
1. What is an algorithm?
2. Why does order matter in an algorithm?
3. The turtle is facing right and you click Turn Left 90°. Now which way is it facing?