Python Turtle Cheat Sheet: All Commands with Examples (+ Printable PDF)

This Python Turtle cheat sheet lists 70 commands in 11 groups, each with a one-line example: moving and turning, the pen, colours and fills, shapes, text, clearing, animation and keyboard and mouse events. Every command name and alias was checked against the turtle module, and every example was run in Python 3.12. For the full reference, see the official turtle documentation.

Download the printable Python Turtle cheat sheet (PDF): the same commands on two A4 pages, ready to print.

Python Turtle cheat sheet printable: all turtle commands grouped by setup, movement, pen, colour, shapes, text, events and animation
Preview of the printable cheat sheet.

Minimal Turtle program (starter template)

Every Turtle program follows the same pattern: import the module, create a screen and a turtle, give drawing commands, and finish with turtle.done() so the window stays open:

import turtle

screen = turtle.Screen()
t = turtle.Turtle()

t.forward(100)
t.left(90)
t.forward(100)

turtle.done()

The examples in the tables below assume screen and t were created like this.

Setup and the window

CommandWhat it doesExample
screen = turtle.Screen()Create (or get) the drawing windowscreen = turtle.Screen()
t = turtle.Turtle()Create a turtle to draw witht = turtle.Turtle()
screen.setup(width, height)Window size in pixelsscreen.setup(800, 600)
screen.title(text)Window titlescreen.title("My drawing")
screen.bgcolor(color)Background colourscreen.bgcolor("lightblue")
screen.bgpic(file)Background image (GIF or PNG)screen.bgpic("bg.gif")
screen.screensize(w, h)Size of the drawing area (adds scrollbars if larger than the window)screen.screensize(1200, 900)
screen.window_width()Current window width (window_height() for height)print(screen.window_width())
turtle.done()Keep the window open until you close it; put it lastturtle.done()
screen.exitonclick()Close the window when it is clickedscreen.exitonclick()
screen.bye()Close the window from codescreen.bye()

Move and turn

CommandWhat it doesExample
t.forward(distance)
alias: fd
Move forward, drawing if the pen is downt.forward(100)
t.backward(distance)
alias: bk, back
Move backward without turningt.backward(50)
t.right(angle)
alias: rt
Turn clockwise by angle degreest.right(90)
t.left(angle)
alias: lt
Turn counterclockwiset.left(45)
t.goto(x, y)
alias: setpos, setposition
Move to a point (draws a line if the pen is down)t.goto(100, 50)
t.teleport(x, y)Jump to a point without drawing (Python 3.12+)t.teleport(-100, 0)
t.setx(x) / t.sety(y)
alias: sety
Change only the x or only the y coordinatet.setx(0)
t.setheading(angle)
alias: seth
Point in a direction: 0 east, 90 north, 180 west, 270 southt.setheading(90)
t.home()Back to (0, 0), facing eastt.home()
t.circle(radius, extent, steps)Circle, arc or regular polygon; negative radius goes clockwiset.circle(50, 180)
t.dot(size, color)Filled dot at the current positiont.dot(20, "red")
t.stamp()Print a copy of the turtle shape; returns an idsid = t.stamp()
t.clearstamp(id)
alias: clearstamps
Remove one stamp (clearstamps() removes all)t.clearstamp(sid)
t.undo()Undo the last actiont.undo()
t.speed(speed)1 slowest to 10 fast, 0 = no animation; or "slow", "fast", "fastest"t.speed(0)

Turtle coordinates and headings

The centre of the window is (0, 0). x grows to the right and y grows upwards. Headings are measured counterclockwise from east:

import turtle

screen = turtle.Screen()
screen.setup(700, 520)
screen.title("Turtle coordinates and headings")

t = turtle.Turtle()
t.hideturtle()
t.speed(0)

def jump(x, y):
    t.penup()
    t.goto(x, y)
    t.pendown()

t.color("#bbbbbb")                     # x and y axes
jump(-330, 0); t.goto(330, 0)
jump(0, -240); t.goto(0, 240)

t.color("black")
jump(8, 6)
t.write("(0, 0)", font=("Arial", 12, "normal"))
for x, y in [(200, 150), (-200, 150), (-200, -150), (200, -150)]:
    jump(x, y)
    t.dot(10, "#306998")
    t.write(f"  ({x}, {y})", font=("Arial", 12, "normal"))

arrow = turtle.Turtle(shape="arrow")   # headings
arrow.color("#c62828")
arrow.penup()
arrow.speed(0)
for angle in (0, 90, 180, 270):
    arrow.home()
    arrow.setheading(angle)
    arrow.forward(80)
    arrow.stamp()
    arrow.forward(34)
    arrow.sety(arrow.ycor() - 9)
    arrow.write(f"{angle}", align="center", font=("Arial", 14, "bold"))
arrow.hideturtle()

turtle.done()
Python Turtle coordinates and heading: (0, 0) in the centre, points at plus and minus 200 and 150, and headings 0, 90, 180 and 270 degrees
(0, 0) is the centre; heading 0 points east and 90 points north.

circle(): circles, arcs and polygons

circle() draws around a centre that is radius units to the turtle’s left. extent draws part of the circle and steps turns it into a regular polygon:

import turtle

screen = turtle.Screen()
screen.setup(820, 360)
screen.title("circle() options")

t = turtle.Turtle()
t.speed(0)
t.pensize(3)
t.color("#306998")

examples = [("circle(50)", {"radius": 50}),
            ("circle(50, 180)", {"radius": 50, "extent": 180}),
            ("circle(50, steps=6)", {"radius": 50, "steps": 6}),
            ("circle(-50)", {"radius": -50})]

for i, (text, kwargs) in enumerate(examples):
    x = -285 + i * 190
    t.penup()
    t.goto(x, -40 if kwargs["radius"] > 0 else 60)
    t.setheading(0)
    t.pendown()
    t.circle(**kwargs)
    t.penup()
    t.goto(x, -90)
    t.write(text, align="center", font=("Consolas", 11, "normal"))

t.hideturtle()
turtle.done()
Python Turtle circle options: full circle, half circle with extent 180, hexagon with steps 6 and a clockwise circle with negative radius
Four ways to call circle().

Where is the turtle?

CommandWhat it doesExample
t.position()
alias: pos
Current (x, y)print(t.position())
t.xcor() / t.ycor()
alias: ycor
Current x or y onlyprint(t.xcor(), t.ycor())
t.heading()Current direction in degreesprint(t.heading())
t.towards(x, y)Angle from the turtle to a pointt.setheading(t.towards(0, 100))
t.distance(x, y)Distance to a point (or to another turtle)print(t.distance(0, 0))

Pen

CommandWhat it doesExample
t.pendown()
alias: pd, down
Draw when movingt.pendown()
t.penup()
alias: pu, up
Move without drawingt.penup()
t.pensize(width)
alias: width
Line thicknesst.pensize(5)
t.isdown()True if the pen is downprint(t.isdown())
t.pen(**settings)Set several pen options at oncet.pen(pencolor="red", pensize=3)
import turtle

screen = turtle.Screen()
screen.setup(640, 360)
screen.title("Pen size and colour")

t = turtle.Turtle()
t.speed(0)
t.hideturtle()

colors = ["black", "#306998", "#2e7d32", "#f9a825", "#c62828"]
for i, size in enumerate([1, 3, 6, 10, 16]):
    y = 110 - i * 50
    t.penup()
    t.goto(-280, y)
    t.pendown()
    t.pensize(size)
    t.pencolor(colors[i])
    t.forward(300)
    t.penup()
    t.forward(20)
    t.write(f"pensize({size})", font=("Consolas", 12, "normal"), align="left")
    t.backward(20)

turtle.done()
Python Turtle pensize example: five lines with pen sizes 1, 3, 6, 10 and 16 in different colours
Pen sizes 1 to 16.

Colour and fill

CommandWhat it doesExample
t.color(pen, fill)Set pen and fill colour togethert.color("red", "yellow")
t.pencolor(color)Line and text colour: name, hex or RGBt.pencolor("#306998")
t.fillcolor(color)Colour used by begin_fill()/end_fill()t.fillcolor("gold")
t.begin_fill() ... t.end_fill()
alias: end_fill
Fill the shape drawn between the two callst.begin_fill(); t.circle(40); t.end_fill()
t.filling()True while a fill is in progressprint(t.filling())
screen.colormode(255)Use RGB values 0 to 255 instead of 0 to 1screen.colormode(255); t.pencolor(255, 140, 0)

Colours can be names ("red"), hex strings ("#306998") or RGB tuples. See Python Turtle colors for a full colour chart.

Turtle shape and visibility

CommandWhat it doesExample
t.shape(name)"arrow", "turtle", "circle", "square", "triangle" or "classic"t.shape("turtle")
t.shapesize(w, l, outline)
alias: turtlesize
Stretch the shape: width, length, outlinet.shapesize(2, 3, 1)
t.hideturtle()
alias: ht
Hide the turtle (drawing is faster)t.hideturtle()
t.showturtle()
alias: st
Show it againt.showturtle()
t.isvisible()True if the turtle is shownprint(t.isvisible())
t.tilt(angle)Rotate the shape without changing the headingt.tilt(30)
screen.register_shape(file)
alias: addshape
Use a GIF image as a turtle shapescreen.register_shape("star.gif"); t.shape("star.gif")
screen.getshapes()List the available shape namesprint(screen.getshapes())
import turtle

screen = turtle.Screen()
screen.setup(660, 340)
screen.title("Turtle shapes")

label = turtle.Turtle(visible=False)
label.penup()

names = ["arrow", "turtle", "circle", "square", "triangle", "classic"]
for i, name in enumerate(names):
    x = -250 + i * 100
    t = turtle.Turtle(shape=name)
    t.penup()
    t.color("#306998", "#9ec5ff")
    t.shapesize(2.5)
    t.goto(x, 30)
    label.goto(x, -50)
    label.write(f'"{name}"', align="center", font=("Arial", 13, "normal"))

turtle.done()