Recently, I was teaching a beginner Python class where students were struggling to visualize programming concepts. That’s when I turned to the Turtle module, a perfect gateway into Python programming that makes learning visual and fun. In this article, I’ll share everything you need to know about drawing shapes using Python’s Turtle module.
The Turtle module provides a simple yet useful way to create graphics. Whether you’re a beginner or looking to create more complex graphics, this guide will walk you through drawing various shapes step by step.
So let’s get in!
What is Python Turtle?
Python Turtle is a pre-installed library that allows you to create pictures and shapes by providing a virtual canvas. The concept comes from “turtle graphics” in the Logo programming language, where a turtle (cursor) moves around the screen with a pen, either up or down.
Think of it as giving commands to a small turtle that drags a pen as it moves across your screen!
Set Up Your Python Turtle Environment
Before we start drawing shapes, let’s set up our environment:
import turtle
# Create a turtle screen
screen = turtle.Screen()
screen.title("Python Turtle Shape Drawing")
# Create a turtle object
my_turtle = turtle.Turtle()
# Set the speed (1-10)
my_turtle.speed(6)This simple setup creates our drawing canvas and a turtle object that we’ll command to draw shapes.
Method 1: Draw Basic Shapes with Turtle
Let me show you how to draw basic shapes with the turtle.
Read Create a Snake Game in Python Using Turtle
Draw a Square
Let’s start with something simple – a square:
def draw_square(size):
for _ in range(4):
my_turtle.forward(size)
my_turtle.right(90)
# Draw a square with side length 100
draw_square(60)I executed the above example code and added the screenshot below.

The process is straightforward – move forward, turn right 90 degrees, and repeat four times to complete a square.
Draw a Rectangle
Drawing a rectangle is similar to a square, but with different lengths:
def draw_rectangle(length, width):
for i in range(4):
if i % 2 == 0:
my_turtle.forward(length)
else:
my_turtle.forward(width)
my_turtle.right(90)
# Draw a rectangle (200×100)
draw_rectangle(200, 100)I executed the above example code and added the screenshot below.

Draw a Triangle
Triangles require us to adjust our angles:
def draw_triangle(size):
for _ in range(3):
my_turtle.forward(size)
my_turtle.left(120)
# Draw an equilateral triangle with side length 150
draw_triangle(150)The key here is to turn 120 degrees after each side (as triangles have interior angles of 60 degrees each).
Check out Attach an Image in Turtle Python
Method 2: Draw Circles and Curved Shapes
Turtle also excels at drawing circles and other curved shapes:
def draw_circle(radius):
my_turtle.circle(radius)
# Draw a circle with radius 75
draw_circle(75)For partial circles or arcs:
def draw_arc(radius, angle):
my_turtle.circle(radius, angle)
# Draw a semicircle with radius 100
draw_arc(100, 180)I executed the above example code and added the screenshot below.

Method 3: Create Complex Polygons
We can create any regular polygon by calculating the correct angle:
def draw_polygon(sides, size):
angle = 360 / sides
for _ in range(sides):
my_turtle.forward(size)
my_turtle.right(angle)
# Draw a pentagon (5 sides)
draw_polygon(5, 100)
# Draw an octagon (8 sides)
draw_polygon(8, 75)This formula works for any regular polygon – just change the number of sides!
Read Python Turtle Colors + Examples
Method 4: Draw a Star
Stars are interesting shapes that require a bit more angle calculation:
def draw_star(size, points):
angle = 180 - (180 / points)
for _ in range(points):
my_turtle.forward(size)
my_turtle.right(angle)
# Draw a 5-pointed star
draw_star(100, 5)Method 5: Create Filled Shapes
Adding color makes our shapes more appealing:
def draw_filled_shape(sides, size, color):
my_turtle.fillcolor(color)
my_turtle.begin_fill()
draw_polygon(sides, size)
my_turtle.end_fill()
# Draw a filled hexagon in blue
draw_filled_shape(6, 80, "blue")Check out Python Turtle Speed With Examples
Practical Example: Create a USA Flag Design
Let’s put our skills to work by drawing a simplified version of the American flag:
def draw_usa_flag():
# Set up
my_turtle.penup()
my_turtle.goto(-200, 100)
my_turtle.pendown()
# Draw the stripes
for i in range(13):
my_turtle.pencolor("black")
if i % 2 == 0:
my_turtle.fillcolor("red")
else:
my_turtle.fillcolor("white")
my_turtle.begin_fill()
for _ in range(2):
my_turtle.forward(400)
my_turtle.right(90)
my_turtle.forward(15)
my_turtle.right(90)
my_turtle.end_fill()
my_turtle.penup()
my_turtle.goto(-200, 100 - (i+1)*15)
my_turtle.pendown()
# Draw blue rectangle for stars
my_turtle.penup()
my_turtle.goto(-200, 100)
my_turtle.pendown()
my_turtle.fillcolor("blue")
my_turtle.begin_fill()
for _ in range(2):
my_turtle.forward(200)
my_turtle.right(90)
my_turtle.forward(195/2)
my_turtle.right(90)
my_turtle.end_fill()
# Add a few stars
my_turtle.pencolor("white")
my_turtle.fillcolor("white")
for row in range(4):
for col in range(5):
my_turtle.penup()
my_turtle.goto(-180 + col*40, 85 - row*20)
my_turtle.pendown()
my_turtle.begin_fill()
for _ in range(5):
my_turtle.forward(10)
my_turtle.right(144)
my_turtle.end_fill()
# Hide the turtle when done
my_turtle.hideturtle()
# Draw the flag
draw_usa_flag()
# Keep the window open
turtle.done()This code creates a simplified American flag with red and white stripes and a blue field with white stars.
Read Python Turtle Circle
Tips for Better Turtle Graphics
Here are some valuable tips I’ve learned over my years working with Python Turtle:
- Use functions: Organize your code into reusable functions for each shape.
- Control the pen: Use
penup()andpendown()to move without drawing. - Set the speed: Adjust the drawing speed with
speed()(1-10, or 0 for fastest). - Position your turtle: Use
goto(x, y)to move to specific coordinates. - Hide the turtle: Use
hideturtle()when finished to show just your drawing.
Troubleshooting Common Issues
If you encounter problems:
- Screen closes immediately: Add
turtle.done()orscreen.exitonclick()at the end of your code. - Turtle moves too slowly/quickly: Adjust the speed with
my_turtle.speed(). - Drawing appears off-screen: Use
screen.setup(width, height)to set appropriate window size.
Python Turtle makes graphics programming accessible and fun for beginners. It’s a great way to visualize algorithmic thinking and create engaging visual output with just a few lines of code.
I hope you found this guide helpful. Whether you’re teaching children the basics of programming or just having fun with Python, Turtle graphics offers an enjoyable way to see your code come to life visually.
You may like to read:

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.