New update is available. Click here to update.

# Panda Using Turtle

Saksham Gupta
Last Updated: Jan 31, 2023
EASY

## Introduction

Turtle is a Python module that comes pre-installed. It contains the features such as Drawing on a computer screen (cardboard), Turtle (pen).

Ninjas are here to help, and today we'll tackle the well-known interview question Draw Panda Using Turtle Graphics in Python.

## Approach

• Turtle should be imported.
• Construct a Turtle Object.
• Define a method for drawing a dynamic radius and color circle.
• Make Panda's ears out of black color circles.
• With a white color circle, draw the face of a Panda.
• Make Panda's eyes out of concentric circles of black and white.
• Make a black circle for the Panda's nose.
• Draw two semicircles below the nose for the mouth.

## Code

``````# Importing Turtle.
import turtle

# Creating a new object.
pen = turtle.Turtle()

# For a circle.
def ring(col, rad):

# Set the fill
pen.fillcolor(col)

# Start filling the color
pen.begin_fill()

# Draw a circle
pen.circle(rad)

# Ending the filling of the color
pen.end_fill()

##### Draw ears #####
# Draw first ear
pen.up()
pen.setpos(-35, 95)
pen.down
ring('black', 15)

# Draw second ear
pen.up()
pen.setpos(35, 95)
pen.down()
ring('black', 15)

##### Draw face #####
pen.up()
pen.setpos(0, 35)
pen.down()
ring('white', 40)

##### Draw eyes black #####

# Draw first eye
pen.up()
pen.setpos(-18, 75)
pen.down
ring('black', 8)

# Draw second eye
pen.up()
pen.setpos(18, 75)
pen.down()
ring('black', 8)

##### Draw eyes white #####

# Draw first eye
pen.up()
pen.setpos(-18, 77)
pen.down()
ring('white', 4)

# Draw second eye
pen.up()
pen.setpos(18, 77)
pen.down()
ring('white', 4)

##### Draw nose #####
pen.up()
pen.setpos(0, 55)
pen.down
ring('black', 5)

##### Draw 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)
pen.hideturtle()
``````

### Output

You can compile it with online python compiler.

## Frequently asked questions

1. What is Python?
Python is a general-purpose programming language with a high level of abstraction. Its design philosophy prioritizes code readability and makes extensive use of indentation. Its language constructs and object-oriented approach are aimed at assisting programmers in writing clear, logical code for both small and large projects.

2. What is a turtle library?
Turtle is a Python library that comes pre-installed and allows users to create pictures and shapes using a virtual canvas. The turtle is the name of the onscreen pen that you use to draw with, and it is also the name of the library. In short, the Python turtle library is a fun and interactive way for new programmers to get a feel for Python programming.

3. What are the steps to run the turtle module?
There are four steps to executing a turtle program:
1. Add the turtle module to your project.
2. To control, make a turtle.
3. Using the turtle methods, draw around.
4. Run turtle.done().
5. done.

4. What are the attributes of the turtle library?
A location, an orientation (or direction), and a pen are the three attributes of the turtle. Color, width, and on/off state are all attributes of the pen (also called down and up). "Move forward 10 spaces" and "turn left 90 degrees" are commands that the turtle responds to based on its current location.

5. Are there any other Data Structures and Algorithms content in CodeStudio?
Yes, you can practice coding while also answering common interview questions with CodeStudio. The more we practice, the more likely we are to get a job at our dream company.

## Conclusion

In this article, we have extensively discussed how to ‘Draw Panda Using Turtle Graphics in Python’We hope that this blog has helped you enhance your knowledge of turtle graphics and if you would like to learn more, check out our articles on Library. Do upvote our blog to help other ninjas grow. Happy Coding!

Was this article helpful ?
0 upvotes