Draw Panda Using Turtle Graphics in Python
Python’s turtle module makes drawing fun and easy with simple commands. In this tutorial, we’ll draw a cute panda step by step using basic functions like penup(), pendown(), setpos() and circle().
Steps to draw a Panda
Let's understand the step-by-step approach to draw a panda using Python’s turtle module. We’ll build each part like ears, face, eyes, nose and mouth. By drawing one shape at a time.
1. Import Turtle module: The turtle module provides functions to control a pen and draw shapes on a canvas.
import turtle
2. Create a Turtle object: We create a Turtle object named pen that we’ll use to draw.
pen = turtle.Turtle()
3. Define a helper function to draw colored circles: To reduce repetition, we define a reusable function ring() that draws filled circles.
def ring(col, rad):
pen.fillcolor(col) # Set fill color
pen.begin_fill() # Start filling
pen.circle(rad) # Draw circle
pen.end_fill() # End filling
4. Draw Ears: We draw two black circles to represent the ears.
# Left ear
pen.penup()
pen.setpos(-35, 95)
pen.pendown()
ring('black', 15)
# Right ear
pen.penup()
pen.setpos(35, 95)
pen.pendown()
ring('black', 15)
5. Draw Face: A large white circle represents the panda’s face.
pen.penup()
pen.setpos(0, 35)
pen.pendown()
ring('white', 40)
6. Draw Eyes (Black Outer Circles): Each eye starts with a larger black circle for the outline.
# Left eye (black)
pen.penup()
pen.setpos(-18, 75)
pen.pendown()
ring('black', 8)
# Right eye (black)
pen.penup()
pen.setpos(18, 75)
pen.pendown()
ring('black', 8)
7. Draw Eyes (White Inner Circles): Smaller white circles inside the black ones complete the eyes.
# Left eye (white)
pen.penup()
pen.setpos(-18, 77)
pen.pendown()
ring('white', 4)
# Right eye (white)
pen.penup()
pen.setpos(18, 77)
pen.pendown()
ring('white', 4)
8. Draw Nose: A small black circle just below the eyes forms the panda’s nose.
pen.penup()
pen.setpos(0, 55)
pen.pendown()
ring('black', 5)
9. Draw Mouth (Two Semicircles): We draw two arcs below the nose to create a smile.
# Left arc
pen.penup()
pen.setpos(0, 55)
pen.setheading(-90)
pen.pendown()
pen.circle(5, 180)
# Right arc
pen.penup()
pen.setpos(0, 55)
pen.setheading(-90)
pen.pendown()
pen.circle(5, -180)
10. Hide Turtle and Finish: Hide the turtle cursor and keep the window open.
pen.hideturtle()
turtle.done()
Implementation code
import turtle
# object
pen = turtle.Turtle()
# function
def ring(col, rad):
pen.fillcolor(col)
pen.begin_fill()
pen.circle(rad)
pen.end_fill()
# ears
pen.up()
pen.setpos(-35, 95)
pen.down()
ring('black', 15)
pen.up()
pen.setpos(35, 95)
pen.down()
ring('black', 15)
# face
pen.up()
pen.setpos(0, 35)
pen.down()
ring('white', 40)
# eyes
pen.up()
pen.setpos(-18, 75)
pen.down()
ring('black', 8)
pen.up()
pen.setpos(18, 75)
pen.down()
ring('black', 8)
# pupils
pen.up()
pen.setpos(-18, 77)
pen.down()
ring('white', 4)
pen.up()
pen.setpos(18, 77)
pen.down()
ring('white', 4)
# nose
pen.up()
pen.setpos(0, 55)
pen.down()
ring('black', 5)
# mouth
pen.up()
pen.setpos(0, 55)
pen.down()
pen.right(90)
pen.circle(5, 180)
pen.up()
pen.setpos(0, 55)
pen.down()
pen.left(360)
pen.circle(5, -180)
# end
pen.hideturtle()
turtle.done()
Output
