Skip to content
Home » Blog » Indian Flag In Python | Python Turtle Projects | Independence Day

Indian Flag In Python | Python Turtle Projects | Independence Day3 min read

Indian Flag Post Img

Hey Python Programmers, In this Blog Post We will be creating a Our Indian Flag Using Python Turtle As Independence Day is Approaching And the Main Highlighting Thing is That we will be creating Our Indian Flag Using Python Turtle Graphics.

So Let’s Get Started With Creating the Flag, But Before That If You Have Not Read My Previous You can Read this Here:

Modules Used For Creating the Project:

Python Turtle

# Importing Required Modules
import turtle
from turtle import *

Defining the Output Source & Turtle Properties:

# Defining the Output Source Which is our Screen
screen = turtle.Screen()

t = turtle.Turtle()
speed(1000)

t.penup()
t.goto(-200, 125)
t.pendown()

Drawing Indian Flag’s Orange Color Part:

# Indian Flag Color (ORANGE)
t.color("orange")
t.begin_fill()
t.forward(400)
t.right(90)
t.forward(84)
t.right(90)
t.forward(400)
t.end_fill()
t.left(90)
t.forward(84)

Drawing Indian Flag’s Green Color Part:

# Indian Flag Color (GREEN)
t.color("green")
t.begin_fill()
t.forward(84)
t.left(90)
t.forward(400)
t.left(90)
t.forward(84)
t.end_fill()
t.penup()
t.goto(35, 0)
t.pendown()
t.color("navy")
t.begin_fill()
t.circle(35)
t.end_fill()

t.penup()
t.goto(30, 0)
t.pendown()
t.color("white")
t.begin_fill()
t.circle(30)
t.end_fill()

t.penup()
t.goto(-27, -4)
t.pendown()
t.color("navy")
for i in range(24):
    t.begin_fill()
    t.circle(2)
    t.end_fill()
    t.penup()
    t.forward(7)
    t.right(15)
    t.pendown()

Drawing the Ashoka Chakra of the Flag:

# The Ashoka Chakra of the Flag
t.color("navy")
t.penup()
t.goto(10, 0)
t.pendown()
t.begin_fill()
t.circle(10)
t.end_fill()

Drawing 24 Spokes of Indian Flag:

# Spokes Of the Chakra
t.penup()
t.goto(0, 0)
t.pendown()
t.pensize(1)
for i in range(24):
    t.forward(30)
    t.backward(30)
    t.left(15)

turtle.done()

Complete Code:

# Indian Flag Using Python Turtle
# (PROUD TO BE AN INDIAN)
import turtle
from turtle import *

# Defining the Output Source Which is our Screen
screen = turtle.Screen()

t = turtle.Turtle()
speed(1000)

# initially penup()
t.penup()
t.goto(-200, 125)
t.pendown()

 # Indian Flag Color (ORANGE)
t.color("orange")
t.begin_fill()
t.forward(400)
t.right(90)
t.forward(84)
t.right(90)
t.forward(400)
t.end_fill()
t.left(90)
t.forward(84)

# Indian Flag Color (GREEN)
t.color("green")
t.begin_fill()
t.forward(84)
t.left(90)
t.forward(400)
t.left(90)
t.forward(84)
t.end_fill()

t.penup()
t.goto(35, 0)
t.pendown()
t.color("navy")
t.begin_fill()
t.circle(35)
t.end_fill()

t.penup()
t.goto(30, 0)
t.pendown()
t.color("white")
t.begin_fill()
t.circle(30)
t.end_fill()

t.penup()
t.goto(-27, -4)
t.pendown()
t.color("navy")
for i in range(24):
    t.begin_fill()
    t.circle(2)
    t.end_fill()
    t.penup()
    t.forward(7)
    t.right(15)
    t.pendown()

# The Ashoka Chakra of the Flag
t.color("navy")
t.penup()
t.goto(10, 0)
t.pendown()
t.begin_fill()
t.circle(10)
t.end_fill()

# Spokes Of the Chakra
t.penup()
t.goto(0, 0)
t.pendown()
t.pensize(1)
for i in range(24):
    t.forward(30)
    t.backward(30)
    t.left(15)

turtle.done()

So This Was it For this Blog See you In the Next One Till Then Keep Coding Keep Exploring!

DOWNLOAD SOURCE CODE

Tanmay Sinha

Leave a Reply