Getting Started
Write Python turtle code in the editor and click Run or press Ctrl+Enter.
Movement
import turtle as t
t.forward(100) # Move forward
t.backward(50) # Move backward
t.right(90) # Turn right (degrees)
t.left(45) # Turn left (degrees)
t.goto(100, 50) # Move to position
t.setheading(0) # Set heading (0=East)
Pen & Drawing
t.penup() # Stop drawing
t.pendown() # Start drawing
t.pencolor('red') # Pen color
t.fillcolor('blue')# Fill color
t.color('red') # Both pen & fill
t.begin_fill() # Start filled shape
t.end_fill() # End filled shape
t.circle(50) # Draw circle
t.dot(10) # Draw dot
t.write('hello') # Write text
Turtle Appearance
t.shape('turtle') # turtle, classic, arrow,
# circle, square, triangle
t.hideturtle() # Hide cursor
t.showturtle() # Show cursor
t.speed(0) # 0=instant, 1-10=animated
Animation
t.tracer(0) # Disable auto-draw
t.update() # Redraw (use with tracer(0))
# Continuous animation loop:
while True:
t.forward(5)
t.right(3)
t.update()
State
t.xcor() # X position
t.ycor() # Y position
t.heading() # Current angle
t.position() # (x, y) tuple
t.distance(0, 0) # Distance to point
t.isdown() # Is pen down?
t.isvisible() # Is turtle visible?
Keyboard Shortcuts
- Ctrl+Enter - Run code
- Ctrl+S - Save to browser
- Ctrl+/ - Toggle comment
- Escape - Close this dialog