Happy Republic Day

In this tutorial, we have made a Happy Republic day flag hosting scene with the help of Python turtle using different colors to make our page so attractive. We will also cover different examples to make this animated page.

Happy republic day
Happy republic day

Block of code:

In this Happy Republic Day block of code, we will create a rectangle to make a beautiful flag of India.

  • turt.begin_fill() is used to start filling color in the shape.
  • turt.fillcolor(color) is used to fill the color inside the shape.
  • turt.forward(400) is used to move the turtle in the forward direction.
  • turt.right(90) is used to move the turtle in the right direction.
  • turt.end_fill() is used to stop filling color.
def rectangle(color):
    turt.begin_fill()
    turt.fillcolor(color)
    for i in range(2):
        turt.forward(400)
        turt.right(90)
        turt.forward(100)
        turt.right(90)
    turt.end_fill()

Block of code:

In this Happy Republic Day block of code, we will create a rectangle and fill orange color in the rectangle and the top part of the flag.

  • turt=tur.Turtle() is used to make objects.
  • tur.title(“Pythontpoint”) is used to give the title to the window.
  • turt.up() is used to stop drawing.
  • turt.pensize(4) is used to give the size to pen.
  • turt.goto(0,-300) is used to move the turtle at the absolute position.
  • turt.down() is used to start drawing.
  • rectangle(“orange”) is used to draw a rectangle and fill orange color inside the shape.
turt=tur.Turtle()
tur.screensize(500,400)
tur.title("Pythontpoint")
turt.up()
turt.pensize(4)
turt.goto(0,-300)
turt.down()
turt.goto(0,400)
rectangle("orange")

Read:

Python Turtle Chess Game

Block of code:

In this Happy Republic Day block of code, we make an Asoka Chakra which is placed at the middle of the flag.

  • turt.goto(0,300) is used to move the turtle at the absolute position.
  • turt.forward(200) is used to move the turtle in the forward direction.
  • turt.color(“blue”) is used to give the blue color to the turtle.
  • turt.circle(-50) is used to draw the circle shape of the turtle.
turt.goto(0,300)
turt.forward(200)
turt.color("blue")
turt.circle(-50)
turt.setheading(270)
turt.forward(50)
turt.setheading(0)

Block of code:

In this Happy Republic Day block, we created the third rectangle fill the green color inside the triangle and complete our flag.

  • turt.setheading(90) is used to set the heading.
  • turt.forward(50) is used to move the turtle in the forward direction.
  • turt.color(“black”) is used to give the color to the turtle.
  • turt.right(90) is used to move the turtle in the right direction.
  • rectangle(“green”) is used to draw the rectangle and fill the green color inside the rectangle.
turt.setheading(90)
turt.forward(50)
turt.setheading(0)
turt.color("black")
turt.forward(200)
turt.right(90)
turt.forward(100)
turt.right(90)
turt.forward(400)
turt.right(90)
turt.forward(100)
turt.right(90)
turt.goto(0,200)
rectangle("green")

Code:

In the following code, we will learn about how to make a republic day flag with the help of a Python turtle.

  • turt.begin_fill() is used to start filling color.
  • turt.fillcolor(color) is used to fill the color inside the shape.
  • turt.forward(400) is used to move the turtle in the forward direction.
  • turt.right(90) is used to move the turtle in the right direction.
  • turt=tur.Turtle() is used to make objects.
  • tur.screensize(500,400) is used to give the size to the screen.
  • tur.title(“Pythontpoint”) is used to give the title to the window.
  • turt.up() is used to stop the drawing.
  • turt.down() is used to start drawing.
  • turt.color(“blue”) is used to give the color to the turtle here turtle is worked as a pen.
  • turt.setheading(0) is used to set the heading on the screen.
from turtle import *
import turtle as tur
def rectangle(color):
    turt.begin_fill()
    turt.fillcolor(color)
    for i in range(2):
        turt.forward(400)
        turt.right(90)
        turt.forward(100)
        turt.right(90)
    turt.end_fill()

turt=tur.Turtle()
tur.screensize(500,400)
tur.title("Pythontpoint")
turt.up()
turt.pensize(4)
turt.goto(0,-300)
turt.down()
turt.goto(0,400)
rectangle("orange")
turt.goto(0,300)
turt.forward(200)
turt.color("blue")
turt.circle(-50)
turt.setheading(270)
turt.forward(50)
turt.setheading(0)
for i in range(24):
    turt.forward(45)
    turt.bk(45)
    turt.left(15)
turt.setheading(90)
turt.forward(50)
turt.setheading(0)
turt.color("black")
turt.forward(200)
turt.right(90)
turt.forward(100)
turt.right(90)
turt.forward(400)
turt.right(90)
turt.forward(100)
turt.right(90)
turt.goto(0,200)
rectangle("green")
tur.done()

Output:

After running the above code we get the following output in which we can see that a beautiful Indian flag is drawn on the screen.

Happy republic day flag hosting
Happy republic day flag hosting

3 thoughts on “Happy Republic Day”

  1. I’ve been exploring for a bit for any high quality articles or blog posts on this sort of area . Exploring in Yahoo I at last stumbled upon this website. Reading this info So i am happy to convey that I’ve a very good uncanny feeling I discovered exactly what I needed. I most certainly will make sure to don’t forget this website and give it a glance regularly.

    Reply

Leave a Comment