📱 Code Python on your phone with Python Coding - Learn PythonGet the free Android app →
  1. Home
  2. Learn
  3. Turtle commands

Guide · 3 min read

Python turtle commands (cheat sheet)

A complete, practical reference for Python's turtle module — what each command does, its short alias, and a runnable example you can open in Python turtle online.

Quick answerThe essential Python turtle commands are forward(d), backward(d), left(a), right(a), goto(x, y), penup(), pendown(), color(pen, fill), pensize(w), begin_fill()/end_fill(), circle(r), dot(size), write(text), speed(0) and hideturtle(), plus Screen().bgcolor() and done().

Setting up

Run ▸import turtle

t = turtle.Turtle()        # create a turtle (an arrow at 0, 0 facing right)
screen = turtle.Screen()
screen.bgcolor("lavender")
t.forward(100)
turtle.done()              # keep the window open (needed on desktop)

The screen's centre is (0, 0); x grows to the right and y grows upwards. Heading 0 points east and angles go anticlockwise.

Movement

CommandAliasWhat it does
forward(d)fdMove d steps in the current direction
backward(d)bk, backMove backwards
left(a) / right(a)lt / rtTurn a degrees
goto(x, y)setposMove straight to a point
setheading(a)sethFace an absolute direction (0 east, 90 north)
home()Back to (0, 0) facing east
circle(r, extent, steps)Circle or arc; steps=6 draws a hexagon
pos(), heading()Where the turtle is / which way it faces
Run ▸import turtle
t = turtle.Turtle()
t.circle(60)                 # full circle, radius 60
t.penup(); t.goto(150, 0); t.pendown()
t.circle(60, 180)            # half circle
t.penup(); t.goto(-150, 0); t.pendown()
t.circle(60, steps=6)        # hexagon
turtle.done()

Pen and colour

CommandWhat it does
penup() / pendown()Stop / start drawing while moving (pu, pd)
pensize(w)Line thickness (width)
pencolor(c)Line colour
fillcolor(c)Fill colour
color(pen, fill)Both at once; color("red") sets both
turtle.colormode(255)Use RGB values 0–255 instead of 0–1

Colours can be names ("tomato", "navy", "gold"), hex strings ("#2f6db3") or RGB tuples.

Filling shapes

Run ▸import turtle
t = turtle.Turtle()
t.color("darkgreen", "lightgreen")
t.begin_fill()
for _ in range(3):
    t.forward(150)
    t.left(120)
t.end_fill()
turtle.done()

Dots, stamps and text

Run ▸import turtle
t = turtle.Turtle()
t.penup()
for i in range(5):
    t.dot(10 + i * 8, "orange")
    t.forward(50)
t.goto(0, -60)
t.write("Hello turtle!", align="center", font=("Arial", 18, "bold"))
t.hideturtle()
turtle.done()

Speed and visibility

speed(n) sets animation speed from 1 (slowest) to 10 (fast); speed(0) is fastest. hideturtle() hides the arrow for a cleaner picture, showturtle() brings it back. On desktop, screen.tracer(0) plus screen.update() draws everything at once for complex drawings.

Screen commands

Screen() gives the window: bgcolor(c), setup(width, height), title(text), done()/mainloop(), exitonclick(). Event commands — onkey, onclick, listen, ontimer — make interactive desktop programs; in the browser version they're accepted but don't fire.

Ready to build something? Try the 10 turtle projects for beginners.

Practise on your phone too

Python Coding - Learn Python for Android: a real Python 3 interpreter, code editor, 26 example programs and 12 marked exercises.

Get it on Google Play

Frequently asked questions

How do I change the background colour in turtle?

turtle.Screen().bgcolor("black") or simply turtle.bgcolor("black").

How do I move the turtle without drawing?

Call penup(), move with goto() or forward(), then pendown().

How do I draw a filled circle?

Set color("black", "yellow"), then begin_fill(), circle(50), end_fill(). For a quick solid circle, dot(100, "yellow").

Why does my turtle window close immediately?

On desktop Python, end your program with turtle.done() so the window stays open.

Keep going

Published 2026-10-22 · Updated 2026-10-22 · by the Coding Python team · code tested on Python 3