Draw The Great Indian Flag using Python Turtle technical yarana

Introduction

Hi everyone, welcome to our website technicalyarana.com. In this tutorial, we are going to Draw The Great Indian Flag using Python Turtle. Well, this flag is drawn using the python turtle module. As it provides the inbuilt methods that make our task of drawing the picture easily. The number of coding lines is not very long as we have made use of loops to lessen the repetition of the lines of code.

The Indian flag code is simple and easily understandable for the ones who have just begun to learn python and the turtle module. We have also provided the comments in each section for easy understanding.

#import turtle
import turtle
from turtle import *

# screen for output
screen = turtle.Screen()
# Defining a turtle Instance
t = turtle.Turtle()
speed(1)

# initially penup()
t.penup()
t.goto(-200, 125)
t.pendown()
# Orange Rectangle
#white rectangle
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)

# Green Rectangle
t.color("green")
t.begin_fill()
t.forward(84)
t.left(90)
t.forward(400)
t.left(90)
t.forward(84)
t.end_fill()

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

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

#Mini Blue Circles of Flag
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()

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

#The spokes of India Flag
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)

#for stick of the flag
t.color("Brown")
t.pensize(10)
t.penup()
t.goto(-200,125)
t.right(180)
t.pendown()
t.forward(800)

#to hold the
#output window
turtle.don

OutPut :

technicalyarana_admin

Leave a Reply

Your email address will not be published.