Indian Flag Post Img

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

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

Author

  • Tanmay Sinha

    Founder & CEO of MrProgrammer.in | I help Learning Freaks to Step into the World of Programming and Our Mission is to Provide High Quality and Valuable Content to Our Users! We believe that everyone has the potential to learn to code, and we are committed to making that happen. Our courses are designed to be engaging and interactive, and we offer a variety of learning paths to meet the needs of all learners. We are also committed to providing our learners with the support they need to succeed, and we offer a variety of resources to help learners learn at their own pace. If you are interested in learning to code, we encourage you to check out our courses. We are confident that you will find our content to be high-quality, valuable, and makes sense.

Leave a Reply