October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Python Turtle: Draw Shapes with Simple Python Commands

Use Python’s turtle module to draw polygons, circles, arcs and filled shapes by combining movement, turns, loops and pen controls.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Python’s turtle module lets you draw shapes by moving a cursor and turning it: move while the pen is down to make a line, repeat the same movement-and-turn pattern to make a polygon, and use circle() for circles or arcs. The drawing appears on screen as the program runs, which Python’s documentation describes as giving learners “instant, visible feedback.”

How Turtle draws a shape

A turtle has a position, a heading and a pen. forward(distance) moves it in its current heading and draws while the pen is down. left(angle) and right(angle) change its heading; they do not draw a line by themselves. The distance is interpreted in the turtle’s coordinate system, so avoid assuming it always corresponds to a fixed number of screen pixels.

For a first drawing, create a turtle object and repeat its movement commands:

import turtle

pen = turtle.Turtle()

# Draw a square
for _ in range(4):
    pen.forward(100)
    pen.right(90)

turtle.done()

Each pass draws one side and turns the turtle to face the next one. turtle.done() keeps the graphics window open after the drawing commands finish.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Draw polygons by repeating a side and turn

A regular polygon uses equal sides and the same exterior turn at each corner. For a polygon with n sides, use a turn of 360 / n degrees after each side. For example, an equilateral triangle turns 120 degrees, a square 90 degrees and a regular hexagon 60 degrees.

Shape Side-and-turn pattern
Triangle Repeat 3 times: move forward, then turn 120°
Square Repeat 4 times: move forward, then turn 90°
Regular pentagon Repeat 5 times: move forward, then turn 72°
Regular hexagon Repeat 6 times: move forward, then turn 60°

Here is a regular hexagon drawn with a loop:

import turtle

pen = turtle.Turtle()
sides = 6
length = 80

for _ in range(sides):
    pen.forward(length)
    pen.right(360 / sides)

turtle.done()

A loop makes the repeated structure visible and easy to change: adjust sides or length instead of editing each command. Writing each movement explicitly can be helpful for a first tiny example because it exposes every step; loops are more practical for polygons and patterns.

Draw circles and arcs

Call circle(radius) to draw a full circle. Pass an extent to draw only part of one: circle(radius, extent). For example, pen.circle(50, 180) draws a half-circle. Turtle approximates circles with a sequence of small polygon steps, rather than rendering a mathematically perfect curve.

Move without drawing, then change the pen

Raise the pen with penup() (alias up()) before moving to a new position without leaving a line. Call pendown() (alias down()) to resume drawing. This lets one program place several separate figures in the same window:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import turtle

pen = turtle.Turtle()

# Draw a square
for _ in range(4):
    pen.forward(100)
    pen.right(90)

# Move to another starting point without drawing
pen.penup()
pen.goto(140, 0)
pen.pendown()
pen.circle(50)

turtle.done()

Set the outline color with color() and line thickness with width() or pensize(). To set both outline and fill colors in one call, use pen.color("red", "gold").

Fill a shape

Start fill tracking immediately before tracing a closed outline and finish it after the last side. For a triangle:

import turtle

pen = turtle.Turtle()
pen.color("red", "gold")
pen.begin_fill()

for _ in range(3):
    pen.forward(100)
    pen.left(120)

pen.end_fill()
turtle.done()

The line color is red and the interior fill is gold. In Python 3.14 and later, a fill context manager offers another way to mark the drawing block:

with pen.fill():
    for _ in range(3):
        pen.forward(100)
        pen.left(120)

Use begin_fill() and end_fill() if your Python version predates 3.14. For self-intersecting outlines, fill results can depend on the operating system’s graphics implementation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose a coding style that fits the drawing

  • Turtle object: pen = turtle.Turtle() gives commands a clear owner and is easier to extend when a program has multiple turtles. You can also use the functional interface, which is compact for a short demonstration.
  • Loop or explicit calls: explicit commands show every individual step; a loop expresses the repeated rule and makes it easy to scale a polygon or pattern.
  • Fill calls or context manager: the established begin_fill()/end_fill() pair works across older versions; with pen.fill(): is available beginning with Python 3.14.

Prefer import turtle and the explicit turtle. prefix for functions, or create a Turtle() object as above. The Python documentation cautions that from turtle import * imports many names and can create conflicts in larger scripts.

What Turtle is—and is not—suited to

Turtle is a useful way to explore movement, angles, loops and visible program feedback while making simple drawings. It is not a replacement for a general-purpose graphics or image-rendering library when a project needs more extensive rendering capabilities. The turtle cursor’s own shape()—arrow, turtle, circle, square, triangle or the default classic cursor—is separate from the geometric shape traced by movement commands.

Fix a missing Tkinter error

Turtle’s graphics window depends on Tkinter. Python.org’s Windows and macOS installers include it, while some Linux distributions and other platforms package the Tk interface separately. If importing turtle fails with an _tkinter error, check whether your platform’s Tk interface package is installed rather than reinstalling Python without checking.

For version-specific details, see the Python 3.12 turtle documentation and the Python 3.15.0rc3 turtle documentation; the latter is prerelease documentation. Learners who want a structured book can also look at Python for Kids, 2nd Edition, which includes a chapter on Turtle graphics.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.