Related Articles

Related Articles

Draw a snowman using turtle module in Python
  • Difficulty Level : Hard
  • Last Updated : 01 Oct, 2020

Prerequisite: Turtle module, Drawing Shapes

There are many modules in python which depicts graphical illustrations, one of them is turtle, it is an in-built module in Python, which lets the user control a pen(turtle) to draw on screen(drawing board). It is mostly used to illustrate figures, shapes, designs etc.  In this article, we will learn how to draw a snowman using the turtle module. Snowman consists of circular shaped snowballs of various sizes. The body of the snowman is made up of three snowballs placed one over the other. Eyes, nose, and buttons are also circular.  

Below are the steps of the above approach:

  1. Import turtle package. 
  2. Set screen with dimensions and color. 
  3. Create a turtle object with color. 
  4. Create the Snowman by illustrating overlapping circles at particular positions.

Below is the Python program to illustrate a snowman using turtle module:

Python3



filter_none

edit
close

play_arrow

link
brightness_4
code

# Import required module
import turtle
  
  
  
# Create turtle object
t = turtle.Turtle()
  
# Create a screen 
screen =turtle.Screen()
  
# Set background color
screen.bgcolor("sky blue")
  
  
  
# Function to draw body of snowman
def draw_circle(color, radius, x, y):
    t.penup()
    t.fillcolor (color)
    t.goto (x, y)
    t.pendown()
    t.begin_fill()
    t.circle (radius)
    t.end_fill()
  
  
      
# Illustrating snowman 
# Drawing snowman body
draw_circle ("#ffffff", 30, 0, -40)
draw_circle ("#ffffff", 40, 0, -100)
draw_circle ("#ffffff", 60, 0, -200)
  
# Drawing left eye
draw_circle ("#ffffff", 2, -10, -10
  
# Drawing right eye
draw_circle ("#ffffff", 2, 10, -10
  
# Drawing nose
draw_circle ("#FF6600", 3, 0, -15)  
   
# Drawing buttons on
draw_circle ("#ffffff", 2, 0, -35)
draw_circle ("#ffffff", 2, 0, -45)
draw_circle ("#ffffff", 2, 0, -55)
  
  
  
# Function to draw arms 
def create_line(x, y, length, angle):
    t.penup()
    t.goto(x, y)
    t.setheading(angle)
    t.pendown()
    t.forward(length)
    t.setheading(angle + 20)
    t.forward(20)
    t.penup()
    t.back(20)
    t.pendown()
    t.setheading(angle - 20)
    t.forward(20)
    t.penup()
    t.home()
     
  
      
# Drawing left arm
create_line(-70, -50, 50, 160
  
# Drawing right arm
create_line(70, -50, 50, 20
  
  
  
# Drawing hat
t.penup()
t.goto (-35, 8)
t.color ("black")
t.pensize (6)
t.pendown()
t.goto (35, 8)
  
t.goto (30, 8)
t.fillcolor ("black")
t.begin_fill()
t.left (90)
t.forward (15)
t.left (90)
t.forward (60)
t.left (90)
t.forward (15)
t.end_fill()

chevron_right


Output :

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :