Draw Indian Flag Using Python Turtle Module
Last updated July 3, 2023 by Jarvis Silva
In this tutorial I will show you how to draw the Indian Flag using python with code, India is a country with great cultures and people and I am from India so I have decided to create this tutorial on drawing my country flag using my python skills.
We will use the turtle module to create this program in python, turtle is a GUI library with the help of this library you can draw anything in python, we have drawn many things using python turtle module you can see here awesome python turtle programs if interested.
Python Code To Draw Indian Flag
import turtle
from turtle import *
# Creating a screen instance
screen = turtle.Screen()
# Defining a turtle instance
t = turtle.Turtle()
# Setting turtle's speed
speed(3)
# Initially, penup()
t.penup()
# Moving turtle to the starting position for the orange rectangle
t.goto(-400, 250)
# Drawing the orange rectangle
t.pendown()
t.color("orange")
t.begin_fill()
t.forward(800)
t.right(90)
t.forward(167)
t.right(90)
t.forward(800)
t.end_fill()
# Moving turtle to the starting position for the green rectangle
t.left(90)
t.forward(167)
# Drawing the green rectangle
t.color("green")
t.begin_fill()
t.forward(167)
t.left(90)
t.forward(800)
t.left(90)
t.forward(167)
t.end_fill()
# Moving turtle to the starting position for the big blue circle
t.penup()
t.goto(70, 0)
# Drawing the big blue circle
t.pendown()
t.color("navy")
t.begin_fill()
t.circle(70)
t.end_fill()
# Moving turtle to the starting position for the big white circle
t.penup()
t.goto(60, 0)
# Drawing the big white circle
t.pendown()
t.color("white")
t.begin_fill()
t.circle(60)
t.end_fill()
# Drawing the mini blue circles
t.penup()
t.goto(-57, -8)
t.pendown()
t.color("navy")
for i in range(24):
t.begin_fill()
t.circle(3)
t.end_fill()
t.penup()
t.forward(15)
t.right(15)
t.pendown()
# Moving turtle to the starting position for the small blue circle
t.penup()
t.goto(20, 0)
# Drawing the small blue circle
t.pendown()
t.begin_fill()
t.circle(20)
t.end_fill()
# Drawing the spokes
t.penup()
t.goto(0, 0)
t.pendown()
t.pensize(2)
for i in range(24):
t.forward(60)
t.backward(60)
t.left(15)
# Closing the turtle window
turtle.done()
Above is the python code to draw the Indian Flag, I have added comments in the code for you to better understand what each line does.
Now to run this program you need to have python installed on your computer, If you don’t have then follow this guide: Install and setup python on your computer or better use this online python compiler.
Now you have the code, but there is one last thing you need to if you running it on your computer as I have said I have used the turtle library to create this program so you might need to install it.
mostly it comes preinstalled but if you get any errors like turtle module not found the use below command to install.
pip install turtle
So now you have everything setup and you are ready to run the program, so to run this program open a command prompt at your program folder location and paste the below command.
python filename.py
The above command will run the program and it will open a new window and it will start drawing the Indian Flag and below is the finished drawing of the flag.
As you can see we successfully drew the Indian flag, below are some more python drawing tutorials using the turtle module.
- Draw Pikachu using python with code.
- Draw doraemon using python turtle.
- Draw shinchan using python turtle.
- Draw I love you using python turtle.
- Draw Batman logo using python turtle.
- Draw Google Logo using python turtle.
- Make a python calculator using turtle.
- Draw christmas tree using python.
- Draw spiderman in python programming.
- Draw Python Logo Using Python.
- Draw Iron Man using python turtle with code.
- Draw A Heart Using python turtle with code.
- Draw car in python turtle with code.
- Draw a Cat In Python Turtle With Code.
- Draw Panda In Python Turtle With Code.
- Draw Netflix Logo Using Python Turtle.
- Draw Whatsapp Logo Using Python Turtle.
- Draw Windows Logo Using Python.
- Draw Apple Logo Using Python Turtle.
- Draw YouTube Logo Using Python Turtle.
- Draw Snapchat Logo Using Python Turtle.
- Draw TikTok Logo Using Python.
- Draw Instagram Logo Using Python Turtle.
I hope you found what you were looking for from this tutorial, do share this tutorial with your indian friends and if you want more python guides and tutorials like this, do join our Telegram channel for future updates.
Thanks for reading, have a nice day 🙂