Python Turtle
import turtle

pen = turtle.Turtle()
pen.speed(0)
colours = ["red", "orange", "gold", "green", "blue", "purple"]

for step in range(120):
    pen.pencolor(colours[step % len(colours)])
    pen.forward(step * 3)
    pen.left(61)

turtle.done()

Press Run or Ctrl ↵ to execute main.py.
Type program input here while it runs.

Python Turtle

Python Turtle Online

Write a turtle program and watch it draw in the Drawing tab beside the editor. It runs in your browser, so there is nothing to install and no sign-in needed, and it works the same on a school Chromebook as on a laptop.

import turtle works as usual, with the same functions and coordinates: (0, 0) is the centre and y goes up. A program you write here also runs on your own computer.

Try it above

A first drawing

This draws a filled gold star and writes under it:

Python Turtle
import turtle

t = turtle.Turtle()
t.color("orange", "gold")
t.begin_fill()
for _ in range(5):
    t.forward(150)
    t.right(144)
t.end_fill()

t.penup()
t.goto(0, -60)
t.write("Well done!", align="center", font=("Arial", 18, "bold"))
t.hideturtle()
turtle.done()
  • speed(0) draws as fast as possible; tracer(0) with update() draws a large picture all at once.
  • circle(r) draws a circle, and circle(r, 180) half of one.
  • The Examples menu in the Drawing tab opens finished programs (a fractal tree, fireworks, a catch-the-dot game) and runs them.

Keys, clicks and timers

onkey(), onscreenclick() and ontimer() work, so you can make small games. Click the drawing to give it the keyboard. On a phone, the keyboard button in the tab’s header shows on-screen arrow keys and Space, plus any other keys your program uses.

Python Turtle
import turtle

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

screen.onkey(lambda: t.forward(20), "Up")
screen.onkey(lambda: t.left(30), "Left")
screen.onkey(lambda: t.right(30), "Right")
screen.listen()
turtle.done()

textinput(), numinput() and input() ask their question in the output under the drawing. Type the answer and press Enter.

Questions

Is this the turtle module from Python?

Python’s own module needs a desktop window, so this page gives import turtle a version built for the browser, with the same functions. A program you write here also runs on your computer.

Is it free?

Yes. Turtle runs in your browser, so it works on every plan, including without an account.

What does not work?

setworldcoordinates(), undo() and images such as bgpic() and .gif shapes. Polygon shapes made with register_shape() do work.

How do I show someone my drawing?

Press Share to get a link to your code. Whoever opens it presses Run and watches it draw, and can change it too.