Happy Ganesh Chaturthi

In this Python tutorial, we will learn to create a sketch of lord Ganesha and wish everyone Happy Ganesh Chaturthi using a python turtle. The turtle is used to draw different shapes, pictures, and images on a screen. Here the turtle is work as a pen and the screen works as a drawing sheet where we can draw different images and shapes.

Happy Ganesh Chaturthi
Happy Ganesh Chaturthi

Happy Ganesh Chaturthi

Ganesh Chaturthi is the festival of Hindus. It is a 10-day festival that is celebrated due to the arrival of Lord Ganesha on the earth from Kailash parvat with his mother Goddess Parvati. The Ganesh Chaturthi is also known as a Vinayaka Chaturthi.

Here we will show you how to draw the sketch of lord Ganesha with the help of Python. Here we will use the turtle module from which we can use to draw the sketch of different things in python.

Block of Code:

Now we are moving forward and starting this project. In this block of code, we are importing all the necessary libraries such as from turtle import *, import turtle as tur, import random, and import time.

from turtle import *
import turtle as tur
import random
import time

Block of Code:

After importing the library, Here we are creating an object of this turtle and after that give the title to the screen.

After that, we are using some of the functions for drawing the shape of the Ganesha.

  • tur.bgcolor(“black”) is used to give the color to the background. Here we are giving the black color to the background.
  • tur.pensize(5) is used to give the size to the pen.
  • tur.left(60) is used to move the turtle in the left direction.
  • tur.fd(50) is used to move the turtle in the forward direction.
  • tur.circle(100,90) is used to draw the circle with the help of circle() function.
  • tur.right(90) is used to move the turtle in the right direction.
t=tur.Turtle()
tur.title("Pythontpoint")
tur.speed(6)

tur.bgcolor("black")
tur.color("red")
tur.pensize(5)

tur.left(60)
tur.fd(50)
tur.left(15)
tur.circle(100,90)
tur.fd(30)
tur .pensize(10)
tur.penup()
tur.right(90)
tur.fd(20)
tur.pendown()

tur.right(40)
tur.circle(-50,90)
tur.fd(20)
tur.left(150)

We can also check the different project codes at pythontpoint Github page to do this you guys can look for us with the following github Username.

Github User Name: PythonT-Point

Block of Code:

Here we are using the function to create a head. For creating the head curve we have to use the following functions.

  • tur.color(“red”) is used to give the color to the pen for drawing the shape.
  • tur.penup() is used to stop the drawing.
  • tur.fd(40) is used to move the turtle in the forward direction.
  • tur.pendown() is used to start drawing the shape.
  • tur.circle(50,90) is used to draw the circle with the help of circle() function.
#seconde head curve
tur.color("red")
tur.penup()
tur.fd(40)
tur.left(20)
tur.pendown()
tur.circle(50,90)

#seconde head curve
tur.color("red")
tur.penup()
tur.fd(40)
tur.left(20)
tur.pendown()
tur.circle(50,90)

#third head curve

#goto beginning
tur.color("red")
tur.penup()
goto(0,0)
tur.pensize(5)
tur.pendown()
tur.left(30)
tur.fd(120)
tur.circle(60,270)

Block of Code:

Here we are using the function to create eyes. For creating the head eyes we have to use the following functions.

  • tur.color(“silver”) is used to give the silver color to the pen.
  • tur.forward(30) is used to move the turtle in the forward direction.
  • tur.right(50) is used to turtle in the right direction.
  • tur.pensize(8) is used to give the size to the pen.
#eyes
tur.color("silver")
tur.penup()
tur.forward(30)
tur.right(50)
tur.forward(135)
tur.pendown()
tur.pensize(8)
tur.circle(50,90)
tur.left(95)
tur.penup()
tur.circle(60,75)

Block of Code:

Here we are using the function to create eyebrows. For creating the head eyebrows we have to use the following functions.

  • tur.penup() is used to stop the drawing.
  • tur.left(90) is used to move the turtle in the left direction.
  • tur.pensize(2) is used to give the size to the pen.
  • tur.pendown() is used to start drawing.
  • tur.circle(70,90) is used to draw the circle with the help of circle() function.
#eyebrows
tur.penup()
tur.forward(15)
tur.left(90)
tur.pensize(2)
tur.pendown()
tur.circle(70,90)

Block of Code:

Here we are using the function to create ears. For creating the ears we have to use the following functions.

  • tur.pensize(5) is used to give the size to the pen.
  • tur.forward(75) is used to move the turtle in the forward direction.
  • tur.circle(90,90) is used to draw the circle with the help of circle() function.
  • tur.right(160) is used to move the turtle in the right direction.
#ears
tur.pensize(5)
tur.penup()
tur.forward(75)
tur.right(90)
tur.forward(20)
tur.pendown()
tur.circle(90,90)
tur.forward(20)

tur.circle(30,170)
tur.right(180)
tur.circle(28,180)
tur.right(160)
tur.circle(25,180)
tur.right(160)
tur.circle(22,160)
tur.forward(20)
tur.circle(60,45)

Block of Code:

Here we are using the function to create a trunk. For creating the trunk we have to use the following functions.

  • tur.penup() is used to stop the drawing.
  • tur.left(130) is used to move the turtle in the left direction.
  • tur.backward(20) is used to move the turtle in the backward direction.
  • tur.right(250) is used to move the turtle in the right direction.
  • tur.pendown() is used to start the drawing.
  • tur.pensize(10) is used to give the size of the turtle.
#trunk

tur.penup()
goto(0,0)
tur.left(130)
tur.fd(140)
tur.right(250)
tur.backward(20)
tur.circle(80,20)
tur.circle(20,40)

tur.right(110)
tur.penup()
tur.fd(20)
tur.pendown()
tur.pensize(10)
tur.forward(50)
tur.circle(100,80)
tur.pensize(9)
tur.circle(150,50)
tur.pensize(7)
tur.circle(100,60)
tur.pensize(5)
tur.circle(90,60)
tur.pensize(4)
tur.circle(40,60)
tur.circle(10,90)

Block of Code:

Here we are using the function to create a head. For creating the head we have to use the following functions.

  • tur.penup() is used to stop the drawing.
  • tur.right(230) is used to move the turtle in the right direction.
  • tur.circle(-100,50) is used to draw the circle by using circle() function.
  • tur.fd(40) is used to move the turtle in the forward direction.
  • tur.right(90) is used to move the turtle in the right direction.
  • tur.pensize(1) is used to give the size to the pen.

#head
tur.color("red")
tur.penup()

goto(0,0)

goto(-90,290)
tur.right(230)
tur.pendown()

tur.circle(-100,50)
tur.circle(200,20)
tur.circle(50,30)

tur.right(180)

tur.circle(50,30)
tur.circle(200,20)
tur.circle(-100,40)
tur.right(95)
tur.penup()
tur.fd(40)
tur.right(90)
tur.pendown()
tur.circle(100,40)
tur.penup()
tur.circle(35,120)
tur.right(30)
tur.pendown()
tur.pensize(1)
tur.circle(60,50)

#done

After splitting the code, and explaining how we can draw the sketch of Lord Ganesha using Python Turtle. Now we will see how the output looks like after running the whole code.

from turtle import *
import turtle as tur
import random
import time

t=tur.Turtle()
tur.title("Pythontpoint")
tur.speed(6)

tur.bgcolor("black")
tur.color("red")
tur.pensize(5)

tur.left(60)
tur.fd(50)
tur.left(15)
tur.circle(100,90)
tur.fd(30)
tur .pensize(10)
tur.penup()
tur.right(90)
tur.fd(20)
tur.pendown()

tur.right(40)
tur.circle(-50,90)
tur.fd(20)
tur.left(150)

#seconde head curve
tur.color("red")
tur.penup()
tur.fd(40)
tur.left(20)
tur.pendown()
tur.circle(50,90)

#third head curve

#goto beginning
tur.color("red")
tur.penup()
goto(0,0)
tur.pensize(5)
tur.pendown()
tur.left(30)
tur.fd(120)
tur.circle(60,270)

#eyes
tur.color("silver")
tur.penup()
tur.forward(30)
tur.right(50)
tur.forward(135)
tur.pendown()
tur.pensize(8)
tur.circle(50,90)
tur.left(95)
tur.penup()
tur.circle(60,75)

#eyebrows
tur.penup()
tur.forward(15)
tur.left(90)
tur.pensize(2)
tur.pendown()
tur.circle(70,90)

#ears
tur.pensize(5)
tur.penup()
tur.forward(75)
tur.right(90)
tur.forward(20)
tur.pendown()
tur.circle(90,90)
tur.forward(20)

tur.circle(30,170)
tur.right(180)
tur.circle(28,180)
tur.right(160)
tur.circle(25,180)
tur.right(160)
tur.circle(22,160)
tur.forward(20)
tur.circle(60,45)


#trunk

tur.penup()
goto(0,0)
tur.left(130)
tur.fd(140)
tur.right(250)
tur.backward(20)
tur.circle(80,20)
tur.circle(20,40)

tur.right(110)
tur.penup()
tur.fd(20)
tur.pendown()
tur.pensize(10)
tur.forward(50)
tur.circle(100,80)
tur.pensize(9)
tur.circle(150,50)
tur.pensize(7)
tur.circle(100,60)
tur.pensize(5)
tur.circle(90,60)
tur.pensize(4)
tur.circle(40,60)
tur.circle(10,90)


#head
tur.color("red")
tur.penup()

goto(0,0)

goto(-90,290)
tur.right(230)
tur.pendown()

tur.circle(-100,50)
tur.circle(200,20)
tur.circle(50,30)

tur.right(180)

tur.circle(50,30)
tur.circle(200,20)
tur.circle(-100,40)
tur.right(95)
tur.penup()
tur.fd(40)
tur.right(90)
tur.pendown()
tur.circle(100,40)
tur.penup()
tur.circle(35,120)
tur.right(30)
tur.pendown()
tur.pensize(1)
tur.circle(60,50)

#done
tur.penup()

goto(-70,90)

tur.fillcolor("red")
tur.begin_fill()
tur.circle(20,180)
tur.end_fill()

tur.penup()
tur.left(75)
tur.fillcolor("red")
tur.begin_fill()
tur.circle(70,35)
tur.end_fill()

tur.left(180)
tur.backward(10)
tur.pendown()
tur.left(6)
tur.pensize(5)
tur.color("red")
tur.circle(-80,40)
tur.penup()

goto(0,0)



#borderrrr
tur.write("     Happy Ganesh Chaturthi",font=("arial",20,"normal"),align="left")

tur.color("orange")
goto(-240,420)
tur.right(90)
tur.pendown()
tur.fillcolor("orange")
tur.begin_fill()
tur.forward(275)
tur.right(130)
tur.forward(100)
tur.end_fill()

tur.penup()
goto(0,420)
tur.right(90)

tur.color("orange")
tur.fillcolor("orange")
tur.begin_fill()
tur.fd(100)
tur.right(50)
tur.pendown()
tur.fd(510)
tur.left(90)
tur.right(165)
tur.end_fill()

tur.color("orange")
tur.fillcolor("orange")
tur.begin_fill()
tur.fd(540)
tur.right(70)
tur.fd(20)
tur.end_fill()

tur.color("orange")
tur.fillcolor("orange")
tur.begin_fill()
tur.fd(540)
tur.right(90)
tur.fd(20)
tur.end_fill()


tur.left(30)
tur.color("orange")
tur.fillcolor("")
tur.begin_fill()
tur.fd(205)
tur.right(90)
tur.fd(20)
tur.end_fill()


tur.color("red")
tur.penup()
goto(0,0)
tur.left(118)
tur.fd(240)
tur.right(30)
tur.pendown()
tur.circle(90,65)
tur.penup()
done()

After running the whole code, we get the following output in which we can see that a beautiful sketch is drawn on the screen with the help of turtle.

Happy Ganesh Chaturthi
Happy Ganesh Chaturthi

So, in this tutorial, we have represented how to draw the picture of Lord Ganesha in Python Turtle. And we have also discussed the whole code used in this tutorial.

Do follow the following tutorials also:

Leave a Comment