We use cookies to improve your experience. If you continue to use our site, we'll assume that you're happy with it. :)

A Complete Tutorial in Python to Design an Indian Flag using Turtle

1 min read

As an Indian, it's becomes a very proud moment to create and design our Indian Flag at a level in Programming. In this Tutorial, I'll Provide and Explain that How to Make or Illustrate an Indian Flag in Python Programming using Turtle.

Little about Turtle: It's a Module which Provides Graphics Primitives in Python.

Step 1: Open any Editor (Eg. VS Code)

Step 2: Copy and Paste the Code Provided Below.

Note: Make Sure that you Have Installed Turtle Module on your System.

To Install: Type the Following Command in Command Prompt.

pip install PythonTurtle

Step 3: Source Code.

import turtle
from turtle import *
# screen for output

screen = turtle.Screen()
screen.title("Indian Flag by GeekInsider (geekinsider.in)")

# Defining a turtle Instance
t = turtle.Turtle()
speed(0)
# initially penup()
t.penup()
t.goto(-400250)
t.pendown()
# Orange Rectangle

# white rectangle
t.color("orange")
t.begin_fill()
t.forward(800)
t.right(90)
t.forward(167)
t.right(90)
t.forward(800)
t.end_fill()
t.color("white")
t.left(90)
t.forward(167)

# Green Rectangle
t.color("green")
t.begin_fill()
t.forward(167)
t.left(90)
t.forward(800)
t.left(90)
t.forward(167)
t.end_fill()

# Big Blue Circle

t.penup()
t.goto(700)
t.pendown()
t.color("navy")
t.begin_fill()
t.circle(
70)
t.end_fill()

# Big White Circle

t.penup()
t.goto(600)
t.pendown()
t.color("white")
t.begin_fill()
t.circle(60)
t.end_fill()

# Mini Blue Circles

t.penup()
t.goto(-57, -8)
t.pendown()
t.color("navy")
for i in range(24):
t.begin_fill()
t.circle(3)
t.end_fill()
t.penup()
t.forward(15)
  t.right(15)
t.pendown()

# Small Blue Circle
t.penup()
t.goto(200)
t.pendown()
t.begin_fill()
t.circle(20)
t.end_fill()
# Spokes

t.penup()
t.goto(00)
t.pendown()
t.pensize(2)
for i in range(24):
 t.forward(60)
 t.backward(60)
t.left(15)
# to hold the

# output window

turtle.done()

Step 4: Now, Save the Code and Run it. Here's the Final Preview After all the Creating Animations.

Step 5: You're Done ! 

We Have Created an Indian Flag using Turtle Module in Python. Here's a Video; How the Code Works after Compiling. It's a Animation of Designing an Indian Flag.

Note: This Video is Fast-Forwarded Video: Just for an Idea How an Indian Flag will Get it's Preview.

To Fast Forward or to Speed-Up the Process in the Flag Design into Source Code, you can change the following values inside it as demonstrated below.

Into the Source Code: Find # Defining a Turtle Instance and Change the Values as per your need.

Post a Comment