Recently, I was working on a Python project where I needed to create some geometric visualizations. I found that the Turtle module provides a perfect way to draw shapes, especially triangles. The beauty of Python Turtle is its simplicity and visual feedback that makes it great for beginners and useful for experienced developers alike.
In this article, I’ll cover multiple ways to draw triangles using Python’s Turtle module, from basic equilateral triangles to more complex patterns and colored designs. So let’s dive in!
Methods to Draw Triangles with Python Turtle
Now, I will explain to you the methods to draw triangles with the turtle in Python.
1 – Draw a Basic Equilateral Triangle
The simplest way to draw a triangle is to use the forward and left/right commands in a loop. Here’s how you can create a basic equilateral triangle:
import turtle
# Create a turtle object
t = turtle.Turtle()
# Set drawing speed (1-10)
t.speed(3)
# Draw an equilateral triangle
for i in range(3):
t.forward(100) # Move forward 100 units
t.left(120) # Turn left 120 degrees
# Keep the window open
turtle.done()I executed the above example code and added the screenshot below.

This code creates a simple equilateral triangle with each side measuring 100 pixels. The key here is the 120-degree turn – since an equilateral triangle has three equal 60-degree internal angles, we need to turn the turtle 120 degrees at each corner (the exterior angle).
Read Python Turtle Tracer
2 – Create a Right-Angled Triangle
If you need to draw a right-angled triangle instead, you’ll need to adjust the angles and possibly the side lengths:
import turtle
t = turtle.Turtle()
t.speed(3)
# Draw a right-angled triangle
t.forward(100) # First side
t.left(90) # 90-degree turn (right angle)
t.forward(100) # Second side
t.left(135) # 135-degree turn
t.forward(141) # Hypotenuse (calculated using Pythagorean theorem)
turtle.done()I executed the above example code and added the screenshot below.

In this example, we’ve created a right-angled triangle with two equal sides (forming an isosceles right triangle). The hypotenuse length is calculated using the Pythagorean theorem.
Check out Python Turtle Race
3 – Draw a Triangle Using Coordinates
Another approach is to specify the coordinates of the triangle vertices:
import turtle
t = turtle.Turtle()
t.speed(3)
# Hide the turtle while drawing
t.hideturtle()
# Set up the vertices coordinates
vertices = [(-50, -50), (50, -50), (0, 50)]
# Start from first vertex
t.penup()
t.goto(vertices[0])
t.pendown()
# Draw the triangle
for vertex in vertices:
t.goto(vertex)
# Complete the triangle by returning to the first vertex
t.goto(vertices[0])
turtle.done()I executed the above example code and added the screenshot below.

This method gives you more control over the exact shape and position of your triangle, as you can precisely define where each corner should be.
4 – Filled Triangle with Color
If you want to create a filled triangle with color, you can use the begin_fill() and end_fill() methods:
import turtle
t = turtle.Turtle()
t.speed(3)
# Set fill color
t.fillcolor("blue")
t.begin_fill()
# Draw the triangle
for i in range(3):
t.forward(100)
t.left(120)
t.end_fill()
turtle.done()This creates a blue-filled triangle. You can change the fill color to any valid color name or RGB value.
5 – Create Multiple Triangles in a Pattern
You can also create interesting patterns using multiple triangles:
import turtle
import random
t = turtle.Turtle()
t.speed(0) # Fastest speed
# Set up colors
colors = ["red", "blue", "green", "purple", "orange", "yellow"]
# Draw a pattern of triangles
for i in range(12):
# Select a random color
t.color(random.choice(colors))
# Draw a triangle
t.begin_fill()
for j in range(3):
t.forward(100)
t.left(120)
t.end_fill()
# Rotate for the next triangle
t.right(30)
turtle.done()This code creates a beautiful pattern of 12 triangles arranged in a circle, each with a random color from our list.
Check out Python Turtle Dot
6 – Create a Sierpinski Triangle (Fractal)
For those interested in more advanced geometric patterns, the Sierpinski triangle is a famous fractal that can be created using recursive functions:
import turtle
def draw_sierpinski(t, order, size):
if order == 0:
# Draw a filled triangle
t.begin_fill()
for i in range(3):
t.forward(size)
t.left(120)
t.end_fill()
else:
# Recursive case: draw 3 smaller triangles
for i in range(3):
t.forward(size/2)
draw_sierpinski(t, order-1, size/2)
t.forward(size/2)
t.left(120)
# Set up the turtle
t = turtle.Turtle()
t.speed(0) # Fastest speed
t.penup()
t.goto(-200, -150) # Position the turtle
t.pendown()
# Draw a 3rd-order Sierpinski triangle
t.fillcolor("blue")
draw_sierpinski(t, 3, 400)
turtle.done()This creates a level-3 Sierpinski triangle with a size of 400 pixels. The recursive function creates smaller triangles within the main triangle, creating a fascinating fractal pattern.
Read Python Turtle Screen Size
Practical Applications
Python Turtle triangles have several practical applications:
- Educational Tools: Teaching basic programming and geometry concepts.
- Data Visualization: Creating simple graphical representations of triangular data.
- Game Development: Building simple 2D games with triangular elements.
- Art Generation: Creating geometric art with triangular patterns.
For example, if you’re teaching a programming class in a U.S. high school, you might use the Turtle module to illustrate geometric principles while introducing students to Python syntax.
I hope you found this article helpful! Python’s Turtle module offers a simple yet useful way to create visual elements, and triangles are just the beginning. You can extend these techniques to create more complex shapes and patterns, combining them with other Python features for even more impressive results.
Other Python tutorials you may also like:

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.