Enjoy Diwali From Python to Diwali: How to Celebrate the Festival of Lights

Techiral
2 min readOct 23, 2022

--

Diwali with Python *Image Generated With DALL-E

From Python to Diwali: How to Celebrate the Festival of Lights:-

Diwali is one of the most popular and widely celebrated festivals in India. The festival of lights, which is also known as Deepavali, is celebrated by Hindus, Sikhs, and Jains all over the world. Diwali marks the victory of good over evil and is celebrated with a lot of pomp and show. People light candles and diyas, exchange gifts and sweets, and pray to Goddess Lakshmi for prosperity.

If you’re looking to add a dash of Diwali festivities to your Python program, here’s how you can do it!

import timeimport calendarfrom datetime import datefrom win10toast import ToastNotifier#Get the current datetoday = date.today()#Get the current monthcurrent_month = today.month#Check if the current month is October or November. If yes, then it is Diwali time!if current_month == 10 or current_month == 11:#Calculate the Diwali dateif current_month == 10:diwali_date = date(today.year, 10, 25)else:diwali_date = date(today.year, 11, 3)#Find the number of days to Diwalidifference = diwali_date — today#Convert the number of days to secondsseconds = difference.days * 24 * 60 * 60#Create a toast notification to wish the user Happy Diwalitoaster = ToastNotifier()toaster.show_toast(“Happy Diwali!”, “Wishing you a happy and prosperous Diwali!”, icon_path=”diwali.ico”, duration=5, threaded=True)#Sleep for the specified number of secondstime.sleep(seconds)else:#It is not Diwali yet!print(“Diwali will be celebrated on “, diwali_date.strftime(“%A, %B %d”))

So, this is how you can add a touch of Diwali to your Python program. You can also use other Python libraries to create more elaborate programs.

For example, you can use the turtle library to draw rangolis or the Tkinter library to create Diwali greeting cards.

Wishing you a happy and prosperous Diwali!

That’s it for Today! Follow my other Social Accounts for more info: Social Links

Thanks For Watching!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Techiral
Techiral

No responses yet

Write a response