Draw with Code
beginner25 XP
Meet the Turtle
Drive a turtle around the screen to draw a garden.
Meet the Turtle 🐢
Python has a little robot turtle that carries a pen. Wherever it walks, it draws a line! You tell it where to go with code:
Python
import turtle
t = turtle.Turtle()
t.forward(100)
t.left(90)
t.forward(100)import turtlebrings the turtle into your program.t = turtle.Turtle()makes a turtle and calls itt.t.forward(100)walks 100 steps forward.t.left(90)turns left by 90 degrees (a corner, like the letter L).
🌱 Draw a square garden
A square has 4 equal sides and 4 corners. Walk, turn, walk, turn...
Python
import turtle
t = turtle.Turtle()
t.color("green")
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)Handy turtle commands
| Command | What it does |
|---|---|
t.forward(50) | walk forward 50 steps |
t.backward(50) | walk backward |
t.left(90) / t.right(90) | turn |
t.color("blue") | change the pen color |
t.penup() / t.pendown() | lift the pen / put it down |
🌾 Fun fact
From an airplane, many farms look like patchworks of squares and rectangles. Farmers plan their fields as shapes, just like your turtle!
Run the garden above, then try changing the numbers to make it bigger or smaller.
⌨️
Type it yourself
Don't just read it — type the example from above into the box, press Run ▶, and watch what happens. Typing it yourself is how it really sticks! Stuck? Tap Show example.
Python · Playground
Output
Press ▶ Run to see your code come to life…Quick check
01/5
Which command turns the turtle to the left?