Pythondex
Turtle Python Programs

Draw Ganpati In Python Turtle With Code

Last updated September 21, 2023 by Jarvis Silva

In this tutorial we will see how to draw ganpati in python programming, Ganpati is a hindu god which is also known as lord ganesha, To draw ganpati we will need to use the turtle module in python which allows us to draw graphics.

This program will just draw ganpati here is new article where I have upload the code to wish happy ganesh chaturthi: Wish happy ganesh chaturthi in python.

Python Code To Draw Ganpati


#imports
import turtle as t
#variables
screen = t.Screen()
ganpati = t.Turtle()
blue = '#10557d'
white = '#ffffff'
red = '#ff0004'
black = '#000000'
yellow = '#ffb700'

screen.title('Ganpati Drawing')
ganpati.shape('turtle')

# pentagon
ganpati.color(blue, blue)
ganpati.begin_fill()
ganpati.left(angle=130)
ganpati.forward(distance=55)
ganpati.right(90)
ganpati.forward(70)
ganpati.right(65)
ganpati.forward(70)
ganpati.right(80)
ganpati.forward(55)
ganpati.right(70)
ganpati.forward(66)
ganpati.end_fill()

ganpati.penup()
ganpati.forward(10)
ganpati.left(90)
ganpati.forward(12.5)
ganpati.pendown()

#square
ganpati.color(yellow, yellow)
ganpati.begin_fill()
ganpati.forward(90)
for _ in range(3):
    ganpati.left(90)
    ganpati.forward(90)
ganpati.end_fill()

ganpati.penup()
ganpati.forward(10)
ganpati.pendown()

#rectangle 1
ganpati.color(red, red)
ganpati.begin_fill()
for _ in range(2):
    ganpati.forward(27.5)
    ganpati.right(90)
    ganpati.backward(90)
    ganpati.right(90)

ganpati.penup()
ganpati.right(180)
ganpati.forward(137.5)
ganpati.pendown()

#rectangle 2
for _ in range(2):
    ganpati.backward(27.5)
    ganpati.right(90)
    ganpati.forward(90)
    ganpati.right(90)
ganpati.end_fill()

ganpati.penup()
ganpati.left(180)
ganpati.forward(57.5)
ganpati.left(90)
ganpati.forward(5)
ganpati.left(90)
ganpati.pendown()

# Bindi line 1
ganpati.color(white)
ganpati.backward(50)

ganpati.penup()
ganpati.right(90)
ganpati.forward(5)
ganpati.left(90)
ganpati.pendown()

#Bindi line 2
ganpati.forward(50)

ganpati.penup()
ganpati.right(90)
ganpati.forward(5)
ganpati.left(90)
ganpati.pendown()

#Bindi line 3
ganpati.backward(50)

ganpati.penup()
ganpati.right(90)
ganpati.forward(10)
ganpati.pendown()

#Eye 1
ganpati.color(black, black)
ganpati.begin_fill()
ganpati.circle(5)

ganpati.penup()
ganpati.left(90)
ganpati.forward(50)
ganpati.pendown()

#Eye 2
ganpati.circle(5)
ganpati.end_fill()

ganpati.penup()
ganpati.right(180)
ganpati.forward(30)
ganpati.left(90)
ganpati.forward(25)
ganpati.pendown()

#Nose
ganpati.color(red, red)
ganpati.begin_fill()
ganpati.forward(100)
ganpati.left(90)
ganpati.forward(50)
ganpati.left(90)
ganpati.forward(20)
ganpati.left(90)
ganpati.forward(30)
ganpati.right(90)
ganpati.forward(80)
ganpati.end_fill()

# finisher
ganpati.penup()
ganpati.forward(1000)

screen.mainloop()

Above is the complete code to draw ganpati using python, copy it and paste it in a python file and run it on your machine or you can use this online python compiler.

We have used the turtle module so you might need to install it if it is not installed already mostly it comes pre-installed with python but incase if you error like module not found use the below command to install.


pip install turtle

After this when you run the program it will open a new window and start drawing ganpati and below is what the finished drawing will look like.

Python Ganpati Output

Below is a YouTube tutorial on drawing ganpati in python. This program was done with the help of this tutorial.

This was for the tutorial for drawing lord ganpati in python if you have knowledge of turtle try making it more better, I hope you found this tutorial helpful and useful. Do share this article with your friends who might be interested in this program.

Here are some more python drawing tutorials:

if you want more python tutorials like this then do join our Telegram channel for future updates, we also post free python resources in the telgram channel.

Thanks for reading, have a nice day 🙂