India Flag Using Python




                        India is going to celebrate the 73 rd Independance Day from United Kingdom tomorrow. Anyway as a programmer we should do something for the our nation. So I created a program in python which will draw the India flag by opening a window. The code is simple and easy. The output of the program is given below👇👇👇👇👇👇👇👇









                                In every programming language we can able to  create everything we want like the graphics etc. Python is one of the easiest programming language. Python is open source and it has a wide number of free tools online. And also it has many graphics tools. One of the most popular and free tool is that the turtle graphics. It is a build in tool in the python ide or you can download manually by using the comment "pip install turtle" before giving this comment make sure that the path is set correctly to your python ide in the environment variables section of your computer. After that initializing the turtle module. Next creating an turtle object. Next declaring a two variables and another two variables for the width and height of the screen where we want the output of the graphics. After that we declaring 3 user defined functions chakra, rectangle boxes (that is: the three rectangels in the indian flag orange, white, and green color)  after defining all the functions. It's time to call all the functions. And that's all we rock just click the run button. And here we go !!!!!!!!!!!!!!!!😄😄😄😄



Python Code:





            The python code is here you can copy the code from here: 


import turtle
import time
screen =turtle.getscreen()
screen.bgcolor("#b3daff")
screen.title("Indian Flag")
tut=turtle.Turtle()
tut.speed(100)
tut.penup()
tut.shape("turtle")
flagheight=300
flagwidth=450
start_x = -225
start_y = 150
ht= flagheight/3
width=flagwidth
radius =ht/2
time.sleep(3)
def recy(x,y, height,width,color):
    tut.goto(x,y)
    tut.color(color)
    tut.begin_fill()
    tut.forward(width)
    tut.right(90)
    tut.forward(height)
    tut.right(90)
    tut.forward(width)
    tut.right(90)
    tut.forward(height)
    tut.right(90)
    tut.end_fill()
    tut.penup()

def stripes():
    x=start_x
    y=start_y
    recy(x,y,ht,width,"#ff9933")
    y=y-ht
    recy(x,y,ht,width,"white")
    y=y-ht
    recy(x,y,ht,width,"#138808")   
    y=y-ht


def chakra():
    tut.speed(100)
    tut.goto(0,0)
    color ="#000080"
    tut.penup()
    tut.color(color)
    tut.fillcolor(color)
    tut.goto(0,0-radius)
    tut.pendown()
    tut.circle(radius)
    for _ in range(24):
        tut.penup()
        tut.goto(0,0)
        tut.left(15)
        tut.pendown()
        tut.forward(radius)

time.sleep(3)
stripes()
chakra()
tut.hideturtle()
time.sleep(5)














Happy Independance Day to all my brothers and sisters.