🇧🇩 Bangladesh flag using python turtle

Today we are here sharing the tutorial of creating Bangladesh FLAG using Python. So let us see the video tutorial, the source code and the output of the program.

SOURCE CODE: BANGLADESH FLAG USING PYTHON

import turtle

# Set up the screen
wn = turtle.Screen()
wn.setup(550, 600, startx=0, starty=100)
wn.title("Bangladesh Flag")

t = turtle.Turtle()
t.speed(5)

# Define the flag dimensions
flag_height = 300
flag_width = 450

# Draw the green rectangle
t.penup()
t.goto(-flag_width / 2, flag_height / 2)
t.pendown()
t.color("#006A4E")
t.begin_fill()
for _ in range(2):
    t.forward(flag_width)
    t.right(90)
    t.forward(flag_height)
    t.right(90)
t.end_fill()

# Draw the red circle
t.penup()
circle_diameter = flag_height * 3/5
circle_radius = circle_diameter / 2
hoist_offset = flag_width / 3 - circle_radius
t.goto(-hoist_offset, -85)  # Position the turtle at the circle's center
t.color("#F42A41")  # hex color for the red circle
t.pendown()
t.begin_fill()
t.circle(circle_radius)
t.end_fill()

# Hide the turtle cursor and display the flag
t.hideturtle()
turtle.done()

OUTPUT:

Also Read: Indian Flag using Python

Leave a Reply

Your email address will not be published. Required fields are marked *