Python Turtle: Cheat Sheet

When I first started exploring Python’s Turtle module over a decade ago, I was amazed by how effortlessly it brought graphics to life. Whether you want to teach kids programming or build simple visualizations, Turtle is a fantastic tool. But as with any library, remembering all the commands and options can quickly become overwhelming.

That’s why I created this Python Turtle cheat sheet, a quick reference guide based on years of hands-on experience. It covers the most essential commands, methods, and tips to help you draw, animate, and customize your Turtle graphics like a pro.

No fluff, just practical advice and examples you can start using right away.

Get Started with Python Turtle

Before getting into commands, you need to import the module and set up your drawing window. Here’s the simplest way:

import turtle

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

This creates a screen where your turtle will draw and a turtle object t that you control.

Read Create a Snake Game in Python Using Turtle

Basic Turtle Commands

I always start by mastering these fundamental commands. They control the turtle’s movement and drawing.

CommandDescriptionExample
t.forward(distance)Moves the turtle forward by the specified distancet.forward(100)
t.backward(distance)Moves the turtle backwardt.backward(50)
t.right(angle)Turns the turtle clockwise by the angle in degreest.right(90)
t.left(angle)Turns the turtle counterclockwiset.left(45)
t.penup()Lifts the pen, stops drawingt.penup()
t.pendown()Puts the pen down, resumes drawingt.pendown()

These commands form the core of drawing shapes and patterns.

Draw Shapes with a Turtle

Drawing shapes is where Turtle shines. Here are some simple methods I use frequently:

Draw a Square

for _ in range(4):
    t.forward(100)
    t.right(90)

I executed the above example code and added the screenshot below.

python turtle cheat sheet

This loop moves the turtle forward 100 units and turns it 90 degrees right, completing a square.

Check out Attach an Image in Turtle Python

Draw a Circle

Turtle has a built-in method to draw circles:

t.circle(50)  # Draws a circle with radius 50

I executed the above example code and added the screenshot below.

turtle python cheat sheet

You can also specify the extent (how much of the circle to draw) and steps (polygon approximation):

t.circle(50, extent=180)  # Half circle
t.circle(50, steps=6)     # Hexagon approximation

Customize Your Turtle

To make your drawings more engaging, you can customize the turtle’s appearance and colors.

Read Python Turtle Colors + Examples

Change Pen Color and Fill Color

t.pencolor("blue")  # Pen color
t.fillcolor("yellow")  # Fill color

I executed the above example code and added the screenshot below.

how to fill color in python turtle

Fill Shapes

To fill a shape with color, use begin_fill() and end_fill():

t.begin_fill()
for _ in range(3):
    t.forward(100)
    t.left(120)
t.end_fill()

This draws and fills a triangle.

Pen Size

You can change the pen thickness:

t.pensize(5)

Control the Turtle’s Speed and Visibility

Speeding up or slowing down the drawing is crucial for both demos and animations.

t.speed(1)  # Slowest
t.speed(10) # Fast
t.speed(0)  # Fastest, no animation

To hide or show the turtle cursor:

t.hideturtle()
t.showturtle()

Work with Coordinates

Sometimes, you want to move the turtle to an exact position without drawing:

t.penup()
t.goto(100, 200)  # Move to (100, 200)
t.pendown()

This is especially useful for complex drawings or resetting the position.

Check out Python Turtle Speed With Examples

Use Multiple Turtles

If you want to create more dynamic scenes, you can create multiple turtles:

t1 = turtle.Turtle()
t2 = turtle.Turtle()

t1.color("red")
t2.color("green")

t1.forward(100)
t2.backward(100)

This allows you to animate different objects independently.

Clear and Resetting the Screen

During development, you might want to clear drawings or reset the turtle:

  • t.clear() clears the drawing but keeps the turtle’s position and state.
  • t.reset() clears the drawing and resets the turtle to the starting position and default settings.
  • screen.clearscreen() clears everything and resets all turtles.

Read Python Turtle Circle

Save Your Drawing as an Image

Python Turtle doesn’t directly support saving drawings as image files, but you can use the getcanvas() method to export the drawing as a PostScript file:

canvas = screen.getcanvas()
canvas.postscript(file="drawing.ps")

You can then convert .ps files to PNG or other formats using external tools like Photoshop or online converters.

Practical Example: Draw the US Flag Stripes

Since many Python learners in the USA enjoy projects with national themes, here’s a quick example of drawing the red stripes of the US flag:

import turtle

screen = turtle.Screen()
screen.title("US Flag Stripes")

stripe = turtle.Turtle()
stripe.speed(0)
stripe.penup()

stripe.goto(-200, 100)

for i in range(13):
    if i % 2 == 0:
        stripe.fillcolor("red")
    else:
        stripe.fillcolor("white")
    stripe.begin_fill()
    for _ in range(2):
        stripe.forward(400)
        stripe.right(90)
        stripe.forward(15)
        stripe.right(90)
    stripe.end_fill()
    stripe.goto(-200, 100 - (i + 1) * 15)

stripe.hideturtle()
screen.mainloop()

This code draws alternating red and white stripes, mimicking the flag’s pattern.

Read Python Turtle Write Function

Tips from My Experience

  • Use loops to avoid repetitive code when drawing shapes or patterns.
  • Combine penup() and goto() to reposition without drawing unwanted lines.
  • Experiment with colors and pen sizes to make your graphics vibrant.
  • Use speed(0) for instant drawing when you want to quickly see the result.
  • Create helper functions for repetitive tasks like drawing stars or stripes.
  • Remember to call screen.mainloop() at the end to keep the window open.

Mastering Python Turtle comes down to practice and creativity. With this cheat sheet, you have a handy reference to speed up your learning and build beautiful graphics.

Feel free to experiment and combine these commands to create your unique designs.

Other Python articles you may also like:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.