Explore

Close
Turtle Programs Share

Draw Indian Flag Using Python Turtle

Draw Indian Flag Using Python Turtle

Want to know how to draw Indian Flag using python, then you are at the right place. Today in this tutorial I will show you how to draw the Indian Flag using python turtle with code, so follow this tutorial till the end.

India is a country with great cultures and people and I am from India so today I have decided to create this tutorial on drawing Indian flag in python turtle.

We will use the turtle module to draw the Indian Flag in python. Turtle is a GUI library with the help of this library you can draw anything in python. 

Don’t worry if you don’t know about this library. I will show you everything on how to create this program and provide you with the code.

Python Code To Draw Indian Flag


import turtle
from turtle import*

#screen for output
screen = turtle.Screen()

# Defining a turtle Instance
t = turtle.Turtle()
speed(3)

# initially penup()
t.penup()
t.goto(-400, 250)
t.pendown()

# Orange Rectangle
#white rectangle
t.color("orange")
t.begin_fill()
t.forward(800)
t.right(90)
t.forward(167)
t.right(90)
t.forward(800)
t.end_fill()
t.left(90)
t.forward(167)

# 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()

# Big Blue Circle
t.penup()
t.goto(70, 0)
t.pendown()
t.color("navy")
t.begin_fill()
t.circle(70)
t.end_fill()

# Big White Circle
t.penup()
t.goto(60, 0)
t.pendown()
t.color("white")
t.begin_fill()
t.circle(60)
t.end_fill()

# 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()
	
# Small Blue Circle
t.penup()
t.goto(20, 0)
t.pendown()
t.begin_fill()
t.circle(20)
t.end_fill()
# 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)
	
turtle.done()

Above is the python code to draw the Indian Flag. 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.

To run this python program, follow the below steps:

  • Create a new folder for this python project.
  • Open it in a code editor of your choice.
  • Create a python file with an ending .py extension.
  • Copy the above code and paste it in your file.

Now you have the code, but there is one last thing you need to do as I have said I have used the turtle library for this program so you might need to install it if you get any errors like turtle module not found.

Turtle comes pre-installed with python setup, but if you get any errors you can install it using the below command.


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 logo.

Indian Flag Drawing

As you can see, we successfully drew the Indian Flag using python turtle. I hope you were able to run this program successfully. 

Want more amazing turtle tutorials like this check out this: Awesome Python Turtle Codes.

Don’t want to create all the files and folders then you can run this program now using this online python compiler it is fast and easy.

Summary

This was the tutorial on drawing the Indian Flag using python turtle. I hope you found this tutorial helpful and useful. Do share this tutorial with your friends who might be interested in this program.

Here are some more python drawing tutorials for you:

I hope you found what you were looking for from this tutorial, 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 🙂