Python Turtle Snowman
Beginner · Festivals · 109 lines · draws in about 12 seconds
This program builds a snowman from three filled circles and decorates it with dots, a carrot nose, stick arms, a scarf and a top hat.

How the code works
A function for each ball of snow
t.color("lightsteelblue", "white") sets two colours at once: a pale blue pen for the edge and white for the inside. Starting at the bottom of the ball puts its centre at (x, y).
def ball(x, y, radius): """A ball of snow centred at (x, y), with a pale blue edge.""" t.penup() t.goto(x, y - radius) t.setheading(0) t.pendown() t.pensize(2) t.color("lightsteelblue", "white") t.begin_fill() t.circle(radius, steps=60) t.end_fill()
Arms with twigs
Each arm goes 85 steps from the shoulder. At the end the turtle turns 35 degrees left for one twig and 70 degrees right for the other, going back after each one.
def arm(x, y, heading): """A stick arm from the shoulder at (x, y), with two twigs at the end.""" t.penup() t.goto(x, y) t.setheading(heading) t.pendown() t.pensize(5) t.color("saddlebrown") t.forward(85) t.left(35) t.forward(25) t.backward(25) t.right(70) t.forward(25) t.backward(25)
Three balls, biggest at the bottom
Each ball is smaller than the one below and overlaps it a little, so there are no gaps. The bottom ball sits over the top of the snowy hill.
ball(0, -115, 85) ball(0, 15, 60) ball(0, 110, 42)
A face made of dots
Each loop goes through a list of places and puts a black dot at each one: two eyes, five dots in a curve for the smile, and three buttons down the middle.
for x, y in [(-15, 122), (15, 122)]: t.goto(x, y) t.dot(10, "black") for x, y in [(-18, 96), (-9, 90), (0, 88), (9, 90), (18, 96)]: t.goto(x, y) t.dot(6, "black") for y in [40, 12, -16]: t.goto(0, y) t.dot(13, "black")
Make it yours
Change the code above and press Run. Some ideas:
- Change
arm(-55, 35, 150)andarm(55, 35, 30)to headings210and-30so the arms point down. - Change
"crimson"in the two scarf lines to"royalblue"for a blue scarf. - Change
range(70)torange(150)for heavier snow.
What it uses
- functions with parameters
- circle and dot
- lists of points
- random with a seed
Every turtle command the site supports is listed on Python turtle online.