  # 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

#### 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 : ```# 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 :

###### ```# 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
set_position(0, 10)
t.circle(circle_x, circle_y)
star()

# Function to draw a star connected to a straight line
set_position(0, 10)
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.

Full Code:-

```import turtle
t = turtle.Turtle()
turtle.Screen().setup(500, 550)
turtle.Screen().bgcolor('black')
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()
def set_position(x, y):
t.penup()
t.goto(x, y)
t.pendown()
t.pensize(10)
set_position(-25, -40)
t.right(60)
t.circle(60, 48)
set_position(-43, -70)
t.right(60)
t.circle(75, 68)
set_position(15, -170)
t.pensize(8)
t.circle(30)
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')
set_position(0, 10)
t.circle(circle_x, circle_y)
star()
set_position(0, 10)
t.forward(forward)
star()
curly_star(145, 75, 60)
curly_star(120, 150, 60)
curly_star(95, 200, 60)
straight_star(90, 200)
curly_star(85, -200, 60)
curly_star(60, -150, 60)
curly_star(35, -75, 60)
# Writing "Happy Diwali" at the bottom
set_position(0, -270)
t.pencolor('pink')
t.write('Happy Diwali', align='center', font=('Arial', 30,))
# Adding a star at the bottom
set_position(0, -290)
star()
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
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)
t.hideturtle()
turtle.done()```

The Turtle module, in Python creates a masterpiece that brings Diwali to life. You all also decide by running the wish code and show it to your friends and wish in a new way. In this program vibrant patterns beautifully depict the Diwali Bomb, which symbolizes Enjoying Diwali .

Happy Birthday Wish Using Python Code

## Final Output In Python:-

First of all, Happy Diwali to all of you, we wished our friends and family in a new way, by coding in a good way, by using the turtle model. stay with us, if anything If you feel there is a need for changing, then comment, your comment is very important for us, if you like our program , then share it with your friends, and you must try it.

Thank you for reading my article, we are always here for you.
Visit my more article: Codewithrandom

Author : Ashutosh Mishra

FAQs:-

### Which module has been used to create this Python program?

`Turtle` module used in this program

`turtle.screen()` function used in this program