Hey, everyone! Today I gonna show you how to draw National Flag of india In python with turtle. Turtle is a popular package that allows us to rendered graphics in python. So, let get started.
Source code :
from turtle import*
import turtle
# create a screen
screen = turtle.Screen()
# Define a turtle instance.
drawer = turtle.Turtle()
speed(0)
drawer.penup()
drawer.goto(-400, 250)
drawer.pendown()
# for creating a Orange and white rectangle.
drawer.color("orange")
drawer.begin_fill()
drawer.forward(800)
drawer.right(90)
drawer.forward(167)
drawer.right(90)
drawer.forward(800)
drawer.end_fill()
drawer.left(90)
drawer.forward(167)
# for creating the green rectangle.
drawer.color('green')
drawer.begin_fill()
drawer.forward(167)
drawer.left(90)
drawer.forward(800)
drawer.left(90)
drawer.forward(167)
drawer.end_fill()
# for creating circle
drawer.penup()
drawer.goto(70, 0)
drawer.pendown()
drawer.color("navy")
drawer.begin_fill()
drawer.circle(70)
drawer.end_fill()
# for creating a white circle
drawer.penup()
drawer.goto(60, 0)
drawer.pendown
drawer.color("white")
drawer.begin_fill()
drawer.circle(60)
drawer.end_fill()
# create a mini blie circle
drawer.penup()
drawer.goto(-57, -8)
drawer.pendown()
drawer.color("navy")
for i in range(24):
drawer.begin_fill()
drawer.circle(3)
drawer.end_fill()
drawer.penup()
drawer.forward(15)
drawer.right(15)
drawer.pendown()
# small blue circle
drawer.penup()
drawer.goto(20, 0)
drawer.pendown()
drawer.begin_fill()
drawer.circle(20)
drawer.end_fill()
# for spokes
drawer.penup()
drawer.goto(0, 0)
drawer.pendown()
drawer.pensize(2)
for x in range(24):
drawer.forward(60)
drawer.backward(60)
drawer.left(15)
# for holding the ouput window
turtle.done()
Output:
If you find this tutorial is helpful for you then please share with your friends. In case of any comment, suggestions or difficulties please drop down in comments box. Stay tuned, stay happy.
0 Comments