What is an algorithm?
In the trifold Instant Challenge you wrote instructions and a partner tried to redraw your picture. Those instructions were an algorithm: a finite set of instructions that accomplish a specific task.
Algorithmic thinking is the process of solving a problem by identifying the tasks required and using algorithms to clearly describe each task. It is a skill — it takes practice and repetition, and it is used far outside of computer science.
Whether it is folding a shirt, parallel parking, or solving a math problem, the expression of any task as a sequence of detailed steps is an algorithm. Algorithms are everywhere.
🧠 Quick check
Two students followed the exact same written instructions and produced two different drawings. What is the best explanation?
A computer will never guess what you meant. Every step has to be clearly defined and in the right order.
Your robot executes sequential statements in the order they appear — no skipping, no guessing. Click the steps in the correct order to build the algorithm, then run the robot.
Available steps (click to add):
Your algorithm:
🔑 Remember
Sequential statements execute in the order they appear in the code segment. Reordering two lines can change the result completely — or break the program.
An algorithm can be represented in multiple ways. Click a description, then click the method it describes.
Descriptions
Methods
Turtle Trainer
Time to turn algorithms into a program. Python's turtle module is predefined, reusable code you import to draw on the screen. The turtle starts at the origin (0, 0) facing east (heading 0) and can turn a full 360 degrees.
Edit the code below and click Run. This simulator runs your code one line at a time, exactly like Python does — and it will complain just like Python does if you make a mistake.
Canvas center = (0, 0). Right is +x, up is +y.
. is the dot operator — it calls a method on your turtle object. The number inside the parentheses is a parameter.
📚 Turtle methods
| Method | What it does |
|---|---|
| .forward(d) | Moves the turtle in the direction it is facing for a distance of d pixels |
| .backward(d) | Moves the turtle backward from the direction it is facing for d pixels |
| .right(a) | Turns the turtle to the right (clockwise) by a degrees |
| .left(a) | Turns the turtle to the left (counterclockwise) by a degrees |
| .circle(r) | Draws a circle with radius r |
| .goto(x, y) | Moves the turtle to location x, y |
| .setheading(h) | Sets the direction the turtle is facing, where h is between 0 and 360 |
| .pencolor(c) | Changes the pen color, where c is a color name such as "red" |
| .penup() | Lifts the pen off the canvas so the turtle moves without drawing |
| .pendown() | Places the pen back on the canvas so you can resume drawing |
| .pensize(s) | Sets the pen size to s |
| .turtlesize(s) | Sets the size of the turtle to s |
Write the algorithm, then run it. Your drawing is compared to the target automatically — the shape has to match in size and form, but you can start it any way you like.
Your drawing
Target
🎨 Final task — recreate your trifold drawing
Open the Turtle Trainer tab (or the PLTW code editor) and write a program that draws the picture you made on section 1 of your trifold. Use at least three different turtle methods and one color change. Share your work as directed.
Show what you know
Answer all 8 questions, then click Grade my exit ticket. One retry allowed.
📝 Computer Science Notebook
Add these to your notebook before you leave:
- An algorithm is a finite set of instructions that accomplish a specific task.
- Algorithmic thinking is identifying the tasks needed to solve a problem and describing each one clearly.
- Algorithms can be represented four ways: natural language, flowcharts, pseudocode, and a programming language.
- Only a programming language can actually be executed by a computer. Pseudocode looks structured but a computer cannot run it.
- Sequential statements execute in the order they appear in the code segment.
- A program is a collection of program statements that performs a specific task when run by a computer.
- A turtle starts at (0, 0) with a heading of 0 degrees (facing east).
.right()turns clockwise,.left()turns counterclockwise. - The dot operator calls a method on an object; the value in the parentheses is a parameter.
🤔 Conclusion questions
- Do you think programmers always write code exactly the same way? Why would it be an advantage for programmers to look at solutions from different perspectives?
- What are the consequences of a poorly written algorithm?