A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/how-to-make-indian-flag-using-turtle-python/ below:

How to Make an Indian Flag in Python

How to Make an Indian Flag in Python

Last Updated : 15 Jul, 2025

Here, we will be making "The Great Indian Flag" using Python. Python's turtle graphics module is built into the Python software installation and is part of the standard library. This means that you don't need to install anything extra to use the turtle lib. Here, we will be using many turtle functions like begin_fill(), end_fill() to fill color inside the Flag, penup(), pendown(), goto(), etc to reaching the target.

Turtle Graphics

In computer graphics, turtle graphics are vector graphics using a relative cursor upon a Cartesian plane. Python Turtle is a drawing board-like feature that lets us command the turtle and draw using it.

Features of turtle graphics:

Approach to Making an Indian Flag in Python Using Turtle

1. Import the turtle modules.

import turtle

2. Get a screen to draw on.

screen = turtle.Screen()

3. Define an instance for turtle(here "t").

4. For making an Indian Flag let's divide the process into 4 steps:

5. Here dimensions of all three Rectangles are (800 units x 167 units), which makes up dimensions of the flag as (800 units x 501 units).

6. The turtle starts from coordinates (-400, 250).

7. Then from that position it makes the First rectangle of orange color.

8. Then from the ending point of the first rectangle, Turtle makes the Second rectangle of no color.

9. Then the Third green color rectangle is made. Now for Ashoka Chakra, we need to perform a set of operations.

10. Finally, The pride of one's Nation is ready. 

Code Implementation Python
import turtle
from turtle import*

#screen for output
screen = turtle.Screen()

# Defining a turtle Instance
t = turtle.Turtle()
speed(0)

# initially penup()
t.penup()
t.goto(-400, 250)
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.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(70, 0)
t.pendown()
t.color("navy")
t.begin_fill()
t.circle(70)
t.end_fill()

# Big White Circle
t.penup()
t.goto(60, 0)
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(20, 0)
t.pendown()
t.begin_fill()
t.circle(20)
t.end_fill()
# Spokes
t.penup()
t.goto(0, 0)
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()

 Output



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4