Python Turtle Art: Create Beautiful Graphics

Recently, I was working on a project where I needed to create some visual elements for a Python workshop. The goal was to engage beginners with something creative and fun. That’s when I revisited the Turtle module, a simple yet useful graphics library built into Python.

In this article, I’ll share some of my favorite Turtle art techniques that I’ve developed over my 10+ years as a Python developer. Whether you’re teaching coding to kids or looking to create custom graphics, Turtle provides an intuitive way to bring your code to life visually.

So let’s dive in!

Get Started with Python Turtle

The Turtle module is inspired by the Logo programming language, where a “turtle” moves around the screen following your commands, drawing as it goes.

Here’s how to set up your first Turtle drawing:

import turtle

# Create a turtle object
t = turtle.Turtle()

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

# Keep the window open
turtle.done()

You can refer to the screenshot below to see the output.

python art code

When you run this code, you’ll see a window pop up with a small arrow (the turtle) drawing a square. The turtle follows your commands one at a time, making it easy to visualize how your code works.

Read Python Turtle Star

Create Basic Shapes with Turtle

Now, I will explain how to create basic shapes with the turtle.

Draw Circles and Spirals

Circles are amazingly simple with Turtle. Here’s how to create a colorful spiral:

import turtle
import random

t = turtle.Turtle()
t.speed(0)  # Fastest speed

# Generate random colors
colors = ["red", "blue", "green", "purple", "yellow", "orange"]

for i in range(50):
    t.color(random.choice(colors))
    t.circle(i * 5)
    t.left(20)

turtle.done()

You can refer to the screenshot below to see the output.

python turtle art

Create Stars and Polygons

Stars are a great way to practice angles. Here’s a function to draw stars with any number of points:

import turtle

def draw_star(turtle_obj, size, points):
    angle = 180 - (180 / points)
    for _ in range(points):
        turtle_obj.forward(size)
        turtle_obj.right(angle)

t = turtle.Turtle()
t.speed(0)
t.penup()
t.goto(-100, 0)
t.pendown()

# Draw a 5-pointed star
draw_star(t, 200, 5)

turtle.done()

You can refer to the screenshot below to see the output.

python turtle art code

Advanced Turtle Art Techniques

Now, I will explain to you the advanced turtle art technologies.

Check out Draw a Flower in Python Turtle

Create Fractals

One of my favorite Turtle projects is creating fractals. Here’s a simple recursive tree fractal:

import turtle

def draw_tree(t, branch_length, angle, depth):
    if depth == 0:
        return

    t.forward(branch_length)
    t.right(angle)

    # Right branch
    draw_tree(t, branch_length * 0.7, angle, depth - 1)

    t.left(angle * 2)

    # Left branch
    draw_tree(t, branch_length * 0.7, angle, depth - 1)

    t.right(angle)
    t.backward(branch_length)

# Set up the turtle
screen = turtle.Screen()
screen.bgcolor("black")

t = turtle.Turtle()
t.color("green")
t.speed(0)
t.penup()
t.goto(0, -250)
t.pendown()
t.left(90)

# Draw the tree
draw_tree(t, 100, 30, 7)

turtle.done()

Create Animated Drawings

You can create simple animations by updating the screen regularly:

import turtle
import math

screen = turtle.Screen()
screen.bgcolor("black")

t = turtle.Turtle()
t.speed(0)
t.hideturtle()

colors = ["red", "purple", "blue", "green", "orange", "yellow"]

for i in range(360):
    t.pencolor(colors[i % 6])
    t.width(i / 100 + 1)
    t.forward(i)
    t.left(59)

    # Update the screen more frequently for smooth animation
    if i % 5 == 0:
        screen.update()

turtle.done()

Create American-Themed Turtle Art

Let me show you how to create American-themed turtle art.

Read Python Turtle Grid

Draw the American Flag

Here’s a practical example, drawing the American flag using Turtle:

import turtle

def draw_rectangle(t, width, height):
    for _ in range(2):
        t.forward(width)
        t.left(90)
        t.forward(height)
        t.left(90)

def draw_star(t, size):
    for _ in range(5):
        t.forward(size)
        t.right(144)

# Set up the screen
screen = turtle.Screen()
screen.setup(800, 500)
screen.title("American Flag")

# Create a turtle
t = turtle.Turtle()
t.speed(0)
t.penup()
t.hideturtle()

# Flag dimensions
flag_width = 500
flag_height = flag_width * 0.526
stripe_height = flag_height / 13
union_width = flag_width * 0.4
union_height = stripe_height * 7
star_size = 10

# Draw the flag background (goto top-left corner)
t.goto(-flag_width/2, flag_height/2)

# Draw the 13 stripes
for i in range(13):
    # Alternate between red and white
    if i % 2 == 0:
        t.fillcolor("red")
    else:
        t.fillcolor("white")

    t.pendown()
    t.begin_fill()
    draw_rectangle(t, flag_width, stripe_height)
    t.end_fill()
    t.penup()
    t.goto(-flag_width/2, flag_height/2 - (i+1)*stripe_height)

# Draw the blue union
t.goto(-flag_width/2, flag_height/2)
t.fillcolor("navy")
t.pendown()
t.begin_fill()
draw_rectangle(t, union_width, union_height)
t.end_fill()
t.penup()

# Draw the 50 stars (5 rows of 6 and 4 rows of 5)
t.fillcolor("white")
star_spacing_x = union_width / 12
star_spacing_y = union_height / 10

# Draw rows of 6 stars
for row in range(0, 9, 2):
    for col in range(6):
        t.goto(-flag_width/2 + star_spacing_x + col*2*star_spacing_x, 
               flag_height/2 - star_spacing_y - row*star_spacing_y)
        t.pendown()
        t.begin_fill()
        draw_star(t, star_size)
        t.end_fill()
        t.penup()

# Draw rows of 5 stars
for row in range(1, 9, 2):
    for col in range(5):
        t.goto(-flag_width/2 + 2*star_spacing_x + col*2*star_spacing_x, 
               flag_height/2 - 2*star_spacing_y - row*star_spacing_y)
        t.pendown()
        t.begin_fill()
        draw_star(t, star_size)
        t.end_fill()
        t.penup()

turtle.done()

Create the Statue of Liberty Silhouette

Another iconic American symbol you can create with Turtle:

import turtle

screen = turtle.Screen()
screen.bgcolor("skyblue")

t = turtle.Turtle()
t.speed(0)
t.hideturtle()

# Draw the statue silhouette
t.penup()
t.goto(-100, -200)
t.pendown()
t.fillcolor("darkgreen")
t.begin_fill()

# Base and pedestal
t.forward(200)
t.left(90)
t.forward(50)
t.left(90)
t.forward(25)
t.right(90)
t.forward(75)
t.left(90)
t.forward(25)
t.right(90)
t.forward(25)

# Body
t.left(20)
t.forward(100)
t.right(20)
t.forward(75)

# Head and crown
t.right(15)
t.forward(40)
t.left(15)
t.forward(20)
t.left(90)
t.forward(10)
t.left(90)
t.forward(10)
t.right(90)
t.forward(15)
t.right(90)
t.forward(10)
t.left(90)
t.forward(10)
t.right(90)
t.forward(15)
t.right(90)
t.forward(10)
t.left(90)
t.forward(10)
t.right(90)
t.forward(15)
t.right(90)
t.forward(10)
t.left(90)
t.forward(10)
t.right(90)
t.forward(15)
t.right(90)
t.forward(10)
t.left(90)
t.forward(10)
t.right(90)
t.forward(15)
t.right(90)
t.forward(15)

# Back of head and torch
t.right(90)
t.forward(35)
t.left(45)
t.forward(25)
t.right(45)
t.forward(25)
t.right(45)
t.forward(15)
t.right(45)
t.forward(15)

# Arm
t.right(25)
t.forward(50)
t.right(25)
t.forward(100)
t.right(15)
t.forward(75)
t.right(15)
t.forward(100)
t.right(90)
t.forward(50)

t.end_fill()

# Add text
t.penup()
t.goto(0, -250)
t.color("navy")
t.write("Liberty", align="center", font=("Arial", 24, "bold"))

turtle.done()

Tips for Creating Better Turtle Art

Here are some tips I’ve learned over the years:

  1. Use the speed() function: Set t.speed(0) for fastest drawing or a lower number for a visible animation.
  2. Hide the turtle: Use t.hideturtle() when creating final art to hide the arrow.
  3. Use pen up and down: Remember to use t.penup() and t.pendown() to move without drawing.
  4. Leverage functions: Create reusable functions for common shapes to keep your code organized.
  5. Use color: Experiment with t.color() and t.fillcolor() along with begin_fill() and end_fill().

Python Turtle is a fantastic tool for teaching programming concepts while creating beautiful art. Whether you’re introducing kids to coding or exploring algorithmic art yourself, the Turtle module offers a perfect blend of simplicity and capability.

I hope you found this guide helpful for creating your own Turtle art projects. If you have any questions or want to share your creations, feel free to leave a comment below!

Other Python articles you may also like:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.