Want to know the Python Program To Wish Happy New Year, then you are at the right place today in this tutorial. I will show you how to create happy new year program in python programming.
You can use this python program to wish happy new year to your friends and relatives. They will surely find it amazing and interesting if they are programmers.
If you are a beginner then don’t worry I will show you exactly how to do it and provide you with the happy new year python code so read till the end.
Happy New Year Python Turtle Code
import turtle from pygame import mixer # Adding music is optional as per your choice. # Initialize pygame mixer mixer.pre_init(frequency=48000, size=-16, channels=2, buffer=512) mixer.init() mixer.music.load("sound.mp3") #add your music file name or path screen = turtle.Screen() screen.bgcolor('#000') screen.title("Happy new year 2022") screen.screensize(800,800) mixer.music.play() firework = turtle.Turtle() firework.pensize(3) firework.shape('turtle') size = 20 firework.stamp firework.speed(11) firework.left(90) firework.color("#EA2027") for step in range(40): firework.forward(100) firework.left(180) firework.forward(100) firework.left(9) firework.color('#EE5A2A') for step in range(36): firework.forward(130) firework.left(180) firework.forward(130) firework.left(10) firework.color('#F79F1F') for step in range(20): firework.forward(150) firework.left(180) firework.forward(150) firework.left(18) firework.color('#3ae374') for stamps in range(12): firework.penup() firework.forward(170) firework.pendown() firework.forward(10) firework.penup() firework.forward(10) firework.stamp() firework.right(30) firework.penup() firework.setpos(0,0) text = turtle.Turtle() text.color("#fff") text.penup() text.setpos(0,-240) text.write("Happy New Year 2022", True, align="center", font=("Monsterrat", 20, "normal")) text.setpos(0,-260) screen.mainloop()
Above is the python code to wish happy new year. It is the happy new year python code 2022 it will wish you this year you can change the program and add any year you want.
First create a new folder for this project, open it in a code editor of your choice, create a python file and paste the above code.
There is a music or sound in this program which will play so you need it run the program you can download the sound file and code file below.
We have used the turtle and pygame module to do this program which comes installed with python setup so you don’t have to manually install it.
But still if you get any errors like turtle or pygame module is not found then you can install both libraries by using the below commands.
# To install turtle pip install turtle # To install pygame pip install pygame
It will install required library on your computer. You can use an online python compiler to run this program or you can run it on your computer.
To run this program you need to open a command prompt or terminal at the project location and paste the below command.
The above command will run the program it will start a new window and wish you happy new year by drawing below is the output of this program.
As you can see we have successfully wished happy new year using python. I hope you ran this program successfully.
This was a Python Program To Wish Happy New Year. I hope you found this tutorial helpful and useful. Do share this guide with your friends who might be interested in this program.
Here are some more python tutorial you might find helpful:
- Python program to check even or odd numbers.
- Python program wish happy birthday.
- Create NxNxN Python Program.
- Build Vending Machine program in python.
- Python program to solve anagrams puzzles.
I hope you found what you were looking for from this python tutorial and if you want more tutorials like this in the future then do join our Telegram channel.
Thanks for reading, Happy new year 🙂