Skip to main content

Drawing an Indian flag using turtle -Python Project

Introduction: 

The Prestigious Indian Flag will be drawn using Python Turtle in this Python project. Turtle is a pre-installed library in Python that helps you draw on a board in your program.

Code Breakdown: 

1. Import Turtle Libary: 
from turtle import Turtle, Screen


2. Configure the Turtle and Screen:
tim = Turtle()
screen = Screen()
screen.setup(width=600, height=600)
screen.title("Indian Flag")


3. Creating Background:
tim.color("lightblue")
tim.goto(-300,300)
tim.begin_fill()
tim.forward(600)
tim.right(90)
tim.forward(300)
tim.right(90)
tim.forward(600)
tim.end_fill()

tim.color("#ADFF2F")
tim.goto(-300,-300)
tim.begin_fill()
tim.right(180)
tim.forward(600)
tim.left(90)
tim.forward(300)
tim.left(90)
tim.forward(600)
tim.end_fill()

4. Drawing the flag's pole:
tim.goto(0,0)
tim.color("Brown")
tim.goto(-30,0)
tim.begin_fill()
tim.right(180)
tim.forward(60)
tim.right(90)
tim.forward(20)
tim.right(90)
tim.forward(60)
tim.end_fill()
tim.goto(-60,-40)
tim.begin_fill()
tim.right(90)
tim.forward(20)
tim.right(90)
tim.forward(120)
tim.right(90)
tim.forward(20)
tim.end_fill()

tim.goto(0,0)
tim.setheading(0)
tim.pensize(10)

tim.color("black")
tim.left(90)
tim.forward(250)
tim.pensize(2)


5. Drawing the flag's Saffron:
tim.color("#FF9933")
tim.begin_fill()
tim.right(90)
tim.forward(200)
tim.right(90)
tim.forward(50)
tim.right(90)
tim.forward(200)
tim.end_fill()


6. Drawing the flag's White:
tim.color("white")
tim.begin_fill()
tim.left(180)
tim.forward(200)
tim.right(90)
tim.forward(50)
tim.right(90)
tim.forward(200)
tim.end_fill()

7. Drawing the flag's Green:
tim.color("green")
tim.begin_fill()
tim.left(180)
tim.forward(200)
tim.right(90)
tim.forward(50)
tim.right(90)
tim.forward(200)
tim.end_fill()

8. Drawing the flag's Ashok Chakra:
tim.color("#000080")
tim.penup()
tim.goto(100,200)
tim.pendown()
tim.circle(25)
tim.penup()
tim.goto(100,175)

y = 0
for _ in range(int(360/15)):
    deg = y + 15
    tim.penup()
    tim.pendown()
    tim.goto(100,175)
    tim.left(deg)
    tim.forward(25)

Output:

Image:


Video:








LinkedIn

Comments

Popular posts from this blog

How to download video from YouTube

https://youtu.be/Cqrpp_8cbSc

NoW days oppo and vivo in india

Now days if you go to market  for buy a smartphone. if you have not decide to what phone you . and ask for phone under 15 k or above . the retalier definently show you vivo and oppo . they will say that it the best  selfie camera phone . then rear camera . ram is 4 gb but mention the DDR series . they told you alltime selfie  phone. It is worst phone if there is no good processor  according to price.            Do you know why they do that ? cause the companies give the them(shopkeeper) a large commision about to 15 %  there other companies give only 5-6% . They dont look that the phone's hardware . just sell it .  then you want a good selfie phone you go for this . good camera  phone you .  you will this  you decide what you want a Selfie phone.  joy hind