Happy Diwali Code in Python

Happy Diwali Wishes using Python Turtle

Hey coder ! Are you excited for this diwali ? Let’s come with us to celebrating and wishing your friends and family through this Python code , So let’s go and start this code in easy to learn wayĀ  , So this year wishing you with this interesting program. now, i have created a Diwali wishing program in python using turtle, in this I have used firework, bomb, text animation in this project.

You all try this code and run the wish code and show it to your friends and wish in a new way.

Happy Diwali Output In Python:-

You all try this code and run the wishing program and show it to your friends and wish in a new way.

How to Prediction the Gender Using Python

lets start code:-

1. importing module and directing the turtle:-

import turtle


t = turtle.Turtle()
turtle.Screen().setup(500, 550)
turtle.Screen().bgcolor('black')

# Draw the outer shape for the diya
t.pencolor('blue')
t.fillcolor('orange')
t.begin_fill()
t.pensize(8)
t.speed(10)

t.right(60)
t.forward(200)
t.goto(0, 0)
t.right(60)
t.forward(200)
t.left(80)
t.circle(160, 78)
t.end_fill()

First, I imported the turtle using the import turtle function and then forwarded it.

1. Output Preview :Ā 

Happy Diwali In Python Code

# Function to set the position of the turtle
def set_position(x, y):
    t.penup()
    t.goto(x, y)
    t.pendown()

# Draw the first curve inside the diya
t.pensize(10)
set_position(-25, -40)
t.right(60)
t.circle(60, 48)

# Draw the second curve inside the diya
set_position(-43, -70)
t.right(60)
t.circle(75, 68)

# Draw the circle in the center of the diya
set_position(15, -170)
t.pensize(8)
t.circle(30)

Using this code, I set the position of the lamp, then curved the design of the lamp, set_position(15, -170) This function sets the position of the turtle.Ā Ā 

2. Output Preview :

Happy Diwali Code in Python
# Function to draw a star
def star():
    t.pensize(2)
    t.pencolor('red')
    t.fillcolor('yellow')
    t.begin_fill()
    for i in range(5):
        t.forward(30)
        t.right(144)
    t.end_fill()
    t.pensize(10)
    t.pencolor('red')

# Function to draw a star connected to a curve
def curly_star(setheading, circle_x, circle_y):
    set_position(0, 10)
    t.setheading(setheading)
    t.circle(circle_x, circle_y)
    star()

# Function to draw a star connected to a straight line
def straight_star(setheading, forward):
    set_position(0, 10)
    t.setheading(setheading)
    t.forward(forward)
    star()

# Draw a series of stars in a curly pattern
curly_star(145, 75, 60)
curly_star(120, 150, 60)
curly_star(95, 200, 60)

# Draw a straight star
straight_star(90, 200)

# Draw a series of stars in a curly pattern in the opposite direction
curly_star(85, -200, 60)
curly_star(60, -150, 60)
curly_star(35, -75, 60)

In this line of code we have combined the curve designs by doing this line of code and then made a star. Def star(): This function creates a 5 pointed star by using the function set_position(0, 10) and then combined the { star. Def straight_star (setheading, forward): } Function to draw the star in a straight line,Ā  step up to project.

3. Output Preview :

# Function to draw a firework pattern
def draw_firework(x, y):
    t.penup()
    t.goto(x, y)
    t.pendown()

    for _ in range(36):
        t.color("orange")
        t.forward(50)
        t.right(170)

# Set up the turtle for drawing fireworks
t = turtle.Turtle()
turtle.Screen().bgcolor('black')
t.speed(10)

# Draw fireworks in each corner
draw_firework(-200, 200)
draw_firework(200, 200)
draw_firework(-200, -200)
draw_firework(200, -200)

# Hide the turtle
t.hideturtle()

# Finish drawing
turtle.done()

draw_firework() This line of code represents the firework and selects the color of the firework, then this turtle.Screen().bgcolor(‘black’) function sets the background color of our program t.hideturtle() This function is used to hide turtle after the program runs and you must try it.

Parking Management System Project Using Python (more…)

Continue ReadingHappy Diwali Code in Python