Tuesday, November 16, 2021

Draw ukraine flag in python turtle

 

Ukraine Flag
Ukraine Flag

About Flag:

Approximately a thousand years ago, a powerful state, Kievan Rus, was founded in the area of Ukraine that is now part of the country. When Ukraine became independent in 1918 and in 1991, Kievan Rus's symbol was a trident head, which was revived when the country entered the modern era.

Ukrainian revolutionaries who wished to free their western parts from Austro-Hungarian rule adopted the first national flag of Ukraine in 1848.

Based on the colors of Lviv's coat of arms, the Lviv flag has horizontal yellow stripes over a blue background.

Late in 1918, to symbolize the symbolism of "blue skies over golden wheat fields," the 1848 flag stripes were reversed to symbolize the golden lion on a blue shield.

The Soviet Union's Red Banner with its golden hammer, sickle, and star was modified for use in Ukraine by adding a horizontal stripe of light blue at the bottom.

After Ukraine declared independence again on August 24, 1991, many fought to maintain a communist system under that flag. Eventually, anticommunist forces won; on January 28, 1992, the nationalist blue-yellow flag replaced the flag of the Soviet Union.

Code:

# Draw ukraine flag in turtle
from turtle import *

bgcolor('black')
hideturtle()  # for hiding turtle icon
speed(5)  # to increasing the speed of output

height=200 # flag height
width=3*height/2 # flag width

x_pos=-width/2 # initial x position
y_pos=height/2 # initial y position

r=[0,255]
g=[87,211]
b=[183,0]

penup() # turtle pointer up
colormode(255)

goto(x_pos,y_pos) # changing the position of the turtle pointer

def draw_rect(height,width):
    pendown() # turtle pointer down
    begin_fill() # beginning the filling
    for i in range(2):
        forward(width) # Forward turtle by width units
        right(90) # Turn right turtle by 90 degree
        forward(height/2) # Forward turtle by height/2 units
        right(90) # Turn right turtle by 90 degree
    end_fill() # ending the filling
    penup() # turtle pointer up
    right(90) # Turn right turtle by 90 degree
    forward(height/2) # Forward turtle by height/2 units
    left(90) # Turn left turtle by 90 degree
# end def

for k in range(2):
    pencolor(r[k],g[k],b[k]) # changing the pen color
    fillcolor(r[k],g[k],b[k]) # filling the color
    draw_rect(height,width) # calling draw_rect() function
# end for

# It will keep output to wait for the click,
# Otherwise output will be disappear.
exitonclick()

Output:

Ukraine Flag Output

No comments:

Post a Comment

Draw bahamas flag in python turtle

  Bahamas Flag