Editor

Draw a Car in Python Turtle

Intermediate · Things to draw · 89 lines · draws in about 10 seconds

The car body is a list of corner points that one polygon function joins and fills, and the wheels go on last so they sit in front.

Draw a Car in Python Turtle: the finished drawing
import turtle
screen = turtle.Screen()
screen.bgcolor("white")
screen.title("Car")
t = turtle.Turtle()
t.speed(8)
def polygon(points, color):
# Join the points with straight lines and fill the shape
t.penup()
t.goto(points[-1])
t.pendown()
t.color(color)
t.begin_fill()
for point in points:
t.goto(point)
t.end_fill()
def wheel(x, y):
# A black tyre with a silver hubcap, centred on (x, y)
t.penup()
t.goto(x, y - 42)
t.setheading(0)
t.color("#222222")
t.begin_fill()
t.circle(42)
t.end_fill()
t.goto(x, y)
t.dot(44, "silver")
t.dot(14, "dimgray")
def cloud(x, y):
# A cloud is three white dots that overlap
t.penup()
t.goto(x, y)
t.dot(60, "white")
t.goto(x + 35, y + 10)
t.dot(70, "white")
t.goto(x + 70, y)
t.dot(55, "white")
# Sky, grass, road and the white dashes down the middle of the road
polygon([(-300, -30), (300, -30), (300, 220), (-300, 220)], "lightskyblue")
polygon([(-300, -70), (300, -70), (300, -30), (-300, -30)], "yellowgreen")
polygon([(-300, -220), (300, -220), (300, -70), (-300, -70)], "dimgray")
t.pensize(6)
t.pencolor("white")
for x in range(-270, 270, 100):
t.penup()
t.goto(x, -170)
t.pendown()
t.forward(40)
t.pensize(1)
cloud(-230, 150)
cloud(130, 170)
# The car body, traced corner by corner from the back bottom
body = [(-210, -50), (215, -50), (222, -10), (205, 15), (90, 25), (40, 85),
(-100, 85), (-160, 25), (-205, 18)]
polygon(body, "crimson")
# Two side windows
polygon([(-143, 32), (-99, 76), (-35, 76), (-35, 32)], "lightcyan")
polygon([(-25, 32), (-25, 76), (37, 76), (74, 32)], "lightcyan")
# Headlight, tail light and a door handle
t.penup()
t.goto(210, 0)
t.dot(18, "gold")
t.goto(-205, 5)
t.dot(14, "orangered")
t.goto(-10, 10)
t.pensize(5)
t.pencolor("darkred")
t.pendown()
t.forward(25)
# Two wheels
wheel(-120, -50)
wheel(125, -50)
t.hideturtle()
turtle.done()

How the code works

Shapes from points

polygon() starts at the last point with the pen up, then visits every point in order, so the shape closes where it began. The sky, the grass, the road, the car body and the windows all use it.

def polygon(points, color):
    # Join the points with straight lines and fill the shape
    t.penup()
    t.goto(points[-1])
    t.pendown()
    t.color(color)
    t.begin_fill()
    for point in points:
        t.goto(point)
    t.end_fill()

Wheels

A tyre is a filled circle(42) that starts 42 below the centre of the wheel. Two dots on top make the hubcap.

def wheel(x, y):
    # A black tyre with a silver hubcap, centred on (x, y)
    t.penup()
    t.goto(x, y - 42)
    t.setheading(0)
    t.color("#222222")
    t.begin_fill()
    t.circle(42)
    t.end_fill()
    t.goto(x, y)
    t.dot(44, "silver")
    t.dot(14, "dimgray")

The body outline

Each pair of numbers is one corner: along the bottom, up the front bumper, back over the hood, up the front window, across the roof and down the back. Change a point and the shape follows.

# The car body, traced corner by corner from the back bottom
body = [(-210, -50), (215, -50), (222, -10), (205, 15), (90, 25), (40, 85),
        (-100, 85), (-160, 25), (-205, 18)]
polygon(body, "crimson")

Wheels last

The wheels are drawn after the body, so they cover its bottom edge. Their centres sit on the bottom of the body, at a y of -50.

# Two wheels
wheel(-120, -50)
wheel(125, -50)

Make it yours

Change the code above and press Run. Some ideas:

  • Change polygon(body, "crimson") to polygon(body, "royalblue") for a blue car.
  • Make the wheels bigger: change both 42s in wheel() to 50.
  • Add a third cloud with cloud(-60, 130) next to the other two.

What it uses

Every turtle command the site supports is listed on Python turtle online.