Python turtle Module
Example
Create a turtle graphics object:
import turtle
x = turtle.Turtle()
y = 5
z = 50
a = 360.0 / y
for i in range(y):
x.forward(z)
x.right(a)
turtle.done()
Try it Yourself »
Definition and Usage
The turtle module provides a simple graphics library for drawing shapes and patterns.
Use it for teaching programming concepts, creating visual art, or building simple graphical applications.
Members
Member | Description |
---|---|
Turtle | Class representing a turtle that draws on screen. |
backward() | Move turtle backward by specified distance. |
circle() | Draw a circle with given radius. |
color() | Set or return pen color and fill color. |
done() | Start event loop and keep window open. |
forward() | Move turtle forward by specified distance. |
left() | Turn turtle left by given angle. |
pendown() | Put pen down to draw when moving. |
penup() | Lift pen up to move without drawing. |
right() | Turn turtle right by given angle. |