Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

Python Turtle Cheat Sheet: Commands, Examples, and Printable Reference

Learn the essential Python Turtle commands for movement, drawing, screen control, events, and input—with examples and a print-ready reference.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python’s turtle module turns movement and pen commands into on-screen drawings. This cheat sheet is based on the Python 3.12.15 reference, accessed October 4, 2026; check the documentation for your installed Python version if you need to confirm a signature or behavior. Python 3.12.15 turtle documentation.

Start with a Turtle script

For a script, import the module as t so it is clear which commands come from Turtle and you avoid importing many names into the global namespace. A standalone drawing should finish with mainloop() so the window stays open until you close it.

As an Amazon Associate I earn from qualifying purchases.

import turtle as t

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

t.mainloop()

This draws a square: the turtle moves 100 units in its current direction, then turns left 90 degrees, repeating four times.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Move and turn the turtle

Movement follows the turtle’s current heading. Turning changes that heading; it does not move the turtle. Use the long command names when learning, and aliases when you want shorter code.

Command What it does Example
forward(distance), fd(distance) Moves forward by the given distance. t.forward(100)
backward(distance), bk(distance), back(distance) Moves backward. t.backward(40)
right(angle), rt(angle) Turns right by an angle in degrees. t.right(90)
left(angle), lt(angle) Turns left by an angle in degrees. t.left(120)
goto(x, y), setpos(x, y), setposition(x, y) Moves to an absolute position. t.goto(50, 25)
teleport(x, y) Moves to a position without drawing a line; see the versioned reference for its full signature and options. t.teleport(0, 0)
setx(x), sety(y) Changes one coordinate while retaining the other. t.setx(80)
setheading(angle), seth(angle) Sets an absolute heading. t.setheading(0)
home() Returns to the origin and default heading. t.home()
circle(radius) Draws a circle or arc according to the supplied radius and optional arguments. t.circle(40)

Control the pen, color, and fill

The pen determines whether movement draws a line. Lift it to reposition without drawing, then lower it to resume drawing.

  • penup() or pu(), up(): stop drawing during movement.
  • pendown() or pd(), down(): draw during movement.
  • color(color): set pen and fill color together; use pencolor(color) or fillcolor(color) to set them separately.
  • width(width) or pensize(width): set the line width.
  • speed(speed): control animation speed.
  • begin_fill() and end_fill(): mark the start and completion of a filled shape. The fill is completed when end_fill() runs.
  • shape(name): select the turtle cursor shape.
import turtle as t

t.color("blue")
t.width(3)
t.penup()
t.goto(0, 0)
t.pendown()
t.begin_fill()
t.circle(40)
t.end_fill()
t.mainloop()

This sets a blue, three-unit line, positions the turtle without leaving a line, and fills the circle when the fill sequence ends.

Read the turtle’s position and state

Command Returns or tells you Example
position(), pos() Current position. where = t.position()
xcor(), ycor() Current x or y coordinate. x = t.xcor()
heading() Current heading. direction = t.heading()
towards(x, y) Heading from the turtle to a position. angle = t.towards(100, 50)
distance(x, y) Distance to a position. d = t.distance(100, 50)

Draw marks, undo, and manage shapes

  • dot(size, color): draw a dot.
  • stamp(): place a copy of the turtle shape at its current location.
  • clearstamp(stampid) and clearstamps(n): remove one stamp or a number of stamps.
  • undo(): undo the last turtle action when available.
  • begin_poly(), end_poly(), and get_poly(): record and retrieve a polygon.
  • clone(): create another turtle with the same initial properties.
  • Pen-state and undo-buffer accessors let a program inspect or configure those features; use the versioned reference for their exact names and signatures.

Choose procedural functions or Turtle and Screen objects

The module supports two interfaces. Procedural calls are convenient for a quick experiment; object-oriented code makes the receiver of each command explicit and supports multiple turtles.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Style Example Best fit
Procedural import turtle
turtle.forward(100)
A short interactive experiment with one turtle.
Object-oriented import turtle
screen = turtle.Screen()
pen = turtle.Turtle()
pen.forward(100)
Scripts where explicit objects, multiple turtles, or clearer organization help.

In object-oriented scripts, keep the screen event loop running with screen.mainloop(). The official tutorial also demonstrates from turtle import * for interactive use, but namespace-qualified imports reduce name-conflict risk in scripts.

Set up the screen and window

  • bgcolor(color): set the background color.
  • bgpic(picname): set the background image.
  • clearscreen(): clear the screen and reset its turtles.
  • resetscreen(): reset the screen’s turtles without the same screen-clearing effect.
  • screensize(): get or set the canvas dimensions.
  • setworldcoordinates(llx, lly, urx, ury): set the coordinate system using lower-left and upper-right bounds.
  • setup(width, height): configure the window size and placement.
  • title(titlestring): set the window title.
  • bye(): close the Turtle window; exitonclick() closes it after a click.

Screen methods belong to the screen, while movement and pen methods belong to a turtle. The module also provides mode(), colormode(), getcanvas(), getshapes(), register_shape() (also addshape()), turtles(), window_height(), and window_width() for modes, shapes, canvas access, and window information.

Handle animation, events, and user input

  • delay(milliseconds), tracer(n, delay), and update(): adjust or refresh drawing animation.
  • listen(): give the screen keyboard focus for key events.
  • onkey(function, key), onkeyrelease(function, key), and onkeypress(function, key): connect keyboard actions to callbacks.
  • onclick(function) and onscreenclick(function): respond to clicks on a turtle or screen.
  • onrelease(function) and ondrag(function): handle turtle mouse release and dragging events.
  • ontimer(function, milliseconds): schedule a callback.
  • textinput(title, prompt) and numinput(title, prompt): request text or numeric input.
  • mainloop() and done(): start the event loop and keep the window active.

Event methods use callbacks: define a function, then register it with the relevant turtle or screen method. Consult the reference for each method’s full parameters and callback behavior.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Keep the window open and fix common setup problems

The drawing window closes when the script finishes

Call t.mainloop() at the end of a procedural script, or screen.mainloop() when using a Screen object. The loop keeps the window responding until it is closed.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python reports that _tkinter is missing

Turtle graphics depends on Tk support. The Python documentation notes that a missing _tkinter component can mean the Tk interface package needs to be installed. The remedy depends on the Python distribution and platform; install or enable the Tk support intended for that Python installation, then try importing turtle again.

Printable reference and complete command inventory

Use your browser’s print command to print or save this reference as a PDF. For a definitive list of every method and its exact signature, consult the Python 3.12.15 turtle reference. The module documentation is versioned, so match the reference to the Python version you run. Python’s documentation describes Turtle as an effective way for learners to encounter programming concepts through visible feedback.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.