◼️
Draw a square
Your first drawing — a square, built with a loop.
Sprout· ages 8–1010 minimportfor loopsturtle graphics
square.py
520×520
First load pulls ~10 MB of Python. Only happens once — the browser caches it after.
What should the output look like?
A square should appear on the canvas.
📖
How this works
The turtle is a little pen that draws lines as it moves. Move forward, turn right, forward, turn right — do that 4 times and you get a square. The for loop just runs the same two instructions 4 times.
Your turn — try these
- 1Change the 100 to a bigger number and rerun. What happens?
- 2Change the 4 in `range(4)` to 3 or 5. Now what shape do you get?
- 3Add `turtle.color("red")` before the loop.