Introduction
Hello friends, welcome to violet-cat-415996.hostingersite.com Today we are going to draw a Dog using Python Turtle module. The picture we are going to draw has very simple lines of code. It helps in easy understanding even for a beginner who has started learning the turtle module of python. In beginning, you will find the code lengthy, Once you go across it and understand it properly you will find everything interesting and easy.
We have made comments on the code for proper understanding as well as explained each block of code properly.
For more understanding and more articles, you can check our website page for python turtle and its projects.
If you want only code, please go to the bottom of the page and copy the code from there using the copy button.
1. Import function
import turtle
Importing the turtle module allows us to use its inbuilt methods and functions in our program.
2. Setting the turtle object
#Set the turtle object t=turtle.Turtle() #Set the screen object as scr scr=t.getscreen() #set the background color scr.bgcolor("Light Blue")
3. Draw the face of the dog
Drawing the face of the dog #Upper semicircle t.pencolor("tan1") t.color("tan1") t.pensize(3) t.penup() t.setheading(90) t.goto(30,-30) t.pendown() t.begin_fill() t.circle(45,180) t.right(90) #Left semicircle t.goto(-45,-30) t.circle(35,190) t.setheading(0) t.forward(55) t.penup() t.setheading(0) t.pendown() #Right semicircle t.circle(35,170) t.penup() t.end_fill()
In this piece of code, we have drawn the face of the dog. It is done by joining three semicircles the upper semicircle, the right semicircle, and the left semicircle. After that, the shape is been filled with the help of the begin_fill function by the color tan1.
4. Draw the tongue of the dog
#Create the tongue of the dog t.pencolor("DeepPink1") t.color("Pink") t.goto(-10,-90) t.setheading(270) t.right(60) t.pendown() t.begin_fill() t.forward(15) t.left(60) t.forward(10) #Drawn the tongues semicircle t.circle(10,180) t.forward(10) t.left(60) t.forward(15) t.end_fill()
In this block of code, we have created the tongue of the dog, and colored the tongue with pink color. Set the heading position to 270 degrees, and drew the tongue, setting the angles and the coordinates.
5.Draw the line on the dog’s Tongue
t.pensize(1)
t.pencolor(“DeepPink”)
t.goto(-13,-90)
t.setheading(270)
t.forward(17)
t.circle(4,180)
t.penup()
t.left(90)
t.forward(8)
t.goto(-13,-107)
t.setheading(270)
t.left(180)
t.pendown()
t.circle(4,-180)
In this part of the code ,we have keep the pensize little bit smaller i.e. 1. It is being done to draw a thin line on the dogs tongue. In this we set position of the line to to x=-13 and y=-90 which is at start of the tongue and drawn a line of 17 steps. After that drawn 2 semicircles of each 180 degrees on the right and left side.
6. Draw the right ear of the dog’s face
#right ear
t.penup()
t.goto(42,-45)
t.pencolor(“brown”)
t.color(“brown”)
t.setheading(0)
t.pendown()
t.begin_fill()
t.forward(10)
t.left(60)
t.circle(35,145)
t.end_fill()
Here, we have drawn the right ear of the dog with setheading position to 0 degree made the angle of 60 degrees. Drawn the right ear with the radius and angle of 35 and 145 degrees respectively.
7. Draw the left ear of the dog
left ear
t.penup()
t.goto(-70,-45)
t.pendown()
t.setheading(180)
t.begin_fill()
t.forward(10)
t.left(-240)
t.circle(35,-145)
t.end_fill()
t.penup()
Here we have drawn the left ear of the dog in a similar way as the right ear. The only difference is in the angle.
7. Draw the right and left black eyes of the dog
#Right black eye t.pencolor("black") t.color("black") t.goto(-5,-45) t.setheading(270) t.pendown() t.begin_fill() t.circle(10,180) t.forward(5) t.circle(10,180) t.forward(5) t.end_fill() t.penup() #Left black eye t.pencolor("black") t.color("black") t.goto(-45,-45) t.setheading(270) t.pendown() t.begin_fill() t.circle(10,180) t.forward(5) t.circle(10,180) t.forward(5) t.end_fill() t.penup()
In this code, we have drawn the right eye and left eye of the dog. Here we have made the eyes in an oval shape. To draw the shape we have used the circle(10,180) and forward(5) function twice.
9. Draw inner white dots of the dog
#right side t.color("white") t.goto(-2,-44) t.begin_fill() t.circle(6) t.end_fill() #left side t.color("white") t.goto(-40,-44) t.begin_fill() t.circle(6) t.end_fill()
In this part, we have drawn the right and left white eyes. The radius is set to 6 and coordinates are changed accordingly.
10. Draw the nose of the dog’s face
#Nose of the dog t.color("black") t.goto(-25,-75) t.begin_fill() t.circle(10) t.end_fill() t.goto(-14,-73) t.color("white") t.begin_fill() t.circle(2) t.end_fill() t.goto(-20,-73) t.color("white") t.begin_fill() t.circle(2) t.end_fill() t.goto(-17,-77) t.color("white") t.begin_fill() t.circle(2) t.end_fill() t.hideturtle() turtle.done()
In this last part, we have drawn the nose of the dog in a circular shape with the color black and a radius of 10. The nose encompasses the 3 white dots at specified coordinates. The three white circles is having a radius of 2. After the completion of the dog face, we have hidden the turtle to get a proper image.
Complete Code to Draw a Dog using Python Turtle
#Imported turtle
import turtle
#set the turtle object
t=turtle.Turtle()
scr=t.getscreen()
scr.bgcolor("Light Blue")
#Drawing the face of the dog
t.pencolor("tan1")
t.color("tan1")
t.pensize(3)
t.penup()
t.setheading(90)
t.goto(30,-30)
t.pendown()
t.begin_fill()
t.circle(45,180)
t.right(90)
t.goto(-45,-30)
t.circle(35,190)
t.setheading(0)
t.forward(55)
t.penup()
t.setheading(0)
t.pendown()
t.circle(35,170)
t.penup()
t.end_fill()
#Create the tongue of the dog
t.pencolor("DeepPink1")
t.color("Pink")
t.setheading(270)
t.goto(-10,-90)
t.right(60)
t.pendown()
t.begin_fill()
t.forward(15)
t.left(60)
t.forward(10)
t.circle(10,180)
t.forward(10)
t.left(60)
t.forward(15)
t.end_fill()
#line on the tongue
t.pensize(1)
t.pencolor("DeepPink")
t.goto(-13,-90)
t.setheading(270)
t.forward(17)
t.circle(4,180)
t.penup()
t.left(90)
t.forward(8)
t.goto(-13,-107)
t.setheading(270)
t.left(180)
t.pendown()
t.circle(4,-180)
#right ear
t.penup()
t.goto(42,-45)
t.pencolor("black")
t.color("sienna")
t.setheading(0)
t.pendown()
t.begin_fill()
t.forward(10)
t.left(60)
t.circle(35,145)
t.end_fill()
#left ear
t.penup()
t.goto(-70,-45)
t.pendown()
t.setheading(180)
t.begin_fill()
t.forward(10)
t.left(-240)
t.circle(35,-145)
t.end_fill()
t.penup()
#eyes
t.pencolor("black")
t.color("black")
t.goto(-5,-45)
t.setheading(270)
t.pendown()
t.begin_fill()
t.circle(10,180)
t.forward(5)
t.circle(10,180)
t.forward(5)
t.end_fill()
t.penup()
t.pencolor("black")
t.color("black")
t.goto(-45,-45)
t.setheading(270)
t.pendown()
t.begin_fill()
t.circle(10,180)
t.forward(5)
t.circle(10,180)
t.forward(5)
t.end_fill()
t.penup()
# Inner white dots in the eye
t.color("white")
t.goto(-2,-44)
t.begin_fill()
t.circle(6)
t.end_fill()
t.color("white")
t.goto(-40,-44)
t.begin_fill()
t.circle(6)
t.end_fill()
#Nose of the dog
t.color("black")
t.goto(-25,-75)
t.begin_fill()
t.circle(10)
t.end_fill()
t.goto(-14,-73)
t.color("white")
t.begin_fill()
t.circle(2)
t.end_fill()
t.goto(-20,-73)
t.color("white")
t.begin_fill()
t.circle(2)
t.end_fill()
t.goto(-17,-77)
t.color("white")
t.begin_fill()
t.circle(2)
t.end_fill()
t.hideturtle()
turtle.done()
Output
In this way, we have successfully created the dog’s face by using python’s turtle module
Thank you for watching this article
Also Read:
- Radha Krishna using Python Turtle
- Drawing letter A using Python Turtle
- Wishing Happy New Year 2023 in Python Turtle
- Snake and Ladder Game in Python
- Draw Goku in Python Turtle
- Draw Mickey Mouse in Python Turtle
- Happy Diwali in Python Turtle
- Draw Halloween in Python Turtle
- Write Happy Halloween in Python Turtle
- Draw Happy Diwali in Python Turtle
- Extract Audio from Video using Python
- Drawing Application in Python Tkinter
- Draw Flag of USA using Python Turtle
- Draw Iron Man Face with Python Turtle: Tony Stark Face
- Draw TikTok Logo with Python Turtle
- Draw Instagram Logo using Python Turtle
- I Love You Text in ASCII Art
- Python Turtle Shapes- Square, Rectangle, Circle
- Python Turtle Commands and All Methods
- Happy Birthday Python Program In Turtle
- I Love You Program In Python Turtle
- Draw Python Logo in Python Turtle
- Space Invaders game using Python
- Draw Google Drive Logo Using Python
- Draw Instagram Reel Logo Using Python
- Draw The Spotify Logo in Python Turtle
- Draw The CRED Logo Using Python Turtle
- Draw Javascript Logo using Python Turtle
- Draw Dell Logo using Python Turtle
- Draw Spider web using Python Turtle