Recommended Free Tools
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.
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.
#1 Best Overall
| 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()orpu(),up(): stop drawing during movement.pendown()orpd(),down(): draw during movement.color(color): set pen and fill color together; usepencolor(color)orfillcolor(color)to set them separately.width(width)orpensize(width): set the line width.speed(speed): control animation speed.begin_fill()andend_fill(): mark the start and completion of a filled shape. The fill is completed whenend_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)andclearstamps(n): remove one stamp or a number of stamps.undo(): undo the last turtle action when available.begin_poly(),end_poly(), andget_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.
| Style | Example | Best fit |
|---|---|---|
| Procedural | import turtle |
A short interactive experiment with one turtle. |
| Object-oriented | import turtle |
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), andupdate(): adjust or refresh drawing animation.listen(): give the screen keyboard focus for key events.onkey(function, key),onkeyrelease(function, key), andonkeypress(function, key): connect keyboard actions to callbacks.onclick(function)andonscreenclick(function): respond to clicks on a turtle or screen.onrelease(function)andondrag(function): handle turtle mouse release and dragging events.ontimer(function, milliseconds): schedule a callback.textinput(title, prompt)andnuminput(title, prompt): request text or numeric input.mainloop()anddone(): 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.
Rank #4
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.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsPython 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.
Quick Recap
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.




