
Introduction
As 2024 comes to a close, itās time to start thinking about the exciting things that 2025 holds! What better way to celebrate the new year than by adding a touch of personal creativity? Instead of sending generic store-bought cards, letās use a bit of Python magic to code our own unique Happy New Year wishes. In this tutorial, you will learn how you can wish Happy New Year 2025 in Python.
We will create two Python programs here. The first one will continuously print Happy New Year 2025 message with random celebrating icons on the terminal or command prompt. The second program will print fascinating colorful ASCII text messages: āHappy New Yearā, ā2025ā same way as the first one.
So, are you ready? Letās start coding!
The First Program
The first program is pretty simple and requires no additional installations. Just run the script, and watch your terminal erupt with a festive shower of Happy New Year 2025 wishes.
To stop, you just need to tap that ctrl+C
combo to break the loop of the program.
Code
import time
from random import randint
for i in range(1,85):
print('')
space = ''
for i in range(1,1000):
count = randint(1, 100)
while(count > 0):
space += ' '
count -= 1
if(i%10==0):
print(space + 'Happy New Year 2025š')
elif(i%9 == 0):
print(space + "šŖ
")
elif(i%5==0):
print(space +"š")
elif(i%8==0):
print(space + "š")
elif(i%7==0):
print(space + "š")
elif(i%6==0):
print(space + "ā¤ļø")
else:
print(space + "šø")
space = ''
time.sleep(0.2)
Output
How the program works?
The basic idea behind this program is to manipulate random numbers. Letās break down how it works.
In the program, Iāve set up a for loop for integer numbers ranging from 1 to 85, but it doesnāt print anything. Then, thereās another for loop with numbers ranging from 1 to 1000. In each iteration, the program generates a random number between 1 and 100, storing it in the count
variable. The program then prints spaces until the count
variable reaches zero.
Following that, the program prints emojis, text, or both based on the modulus result (if i % number
equals zero, where ānumberā is 10, 9, 8, 7, or 6). Finally, for each iteration, the program introduces a delay of 0.2 seconds.
The Second Program
Remember how we displayed āHappy New Year 2025ā in the terminal before? This time, instead of plain text, weāll use Pythonās pyfiglet and termcolor modules to create a colorful ASCII masterpiece.
Want to learn more about these modules? Check out this tutorial: [Wish Your Friends with Stylish Text in Python].
These fancy tools arenāt built-in, so weāll need to install them first. Ready to get started?
Requirements and Installations
Install pyfiglet
and termcolor
with these commands:
- pyfiglet: pip install pyfiglet
- termcolor: pip install termcolor
Download `fonts.txt` file
The program picks a surprise font (from 419 options) and color for your Happy New Year wishes. Instead of listing hundreds of fonts in the code, I saved them in a separate file you can download below. Just click the button, and the program will use that file to choose the perfect font and color for your next message!
Remember, the program needs the āfonts.txtā file to be in the same folder as the program file.
Code
Want to make your New Yearās wish extra special? Just type the personās name in the āmessageā variable!
import time
import time
import random
import pyfiglet as pf
from pyfiglet import Figlet
from termcolor import colored
# The message
Text = "Happy New Year 2025"
# Additional Message/Name of the Person
message = ""
# Reverse your given name
reverseText = message[::-1]
colorList = ['red', 'green', 'yellow', 'blue']
timeInterval = [0.2, 0.3, 0.2, 0.4]
# Getting all the font types from 'font.txt'
# and storing into a list
#==================================
dataList = list()
with open('fonts.txt') as f:
for line in f:
dataList.append(line.strip())
#==================================
# This part of the code prints the message
# with different font types(fixed and randomly)
#==================================
for i in range(1,1000):
if(i%10==0):
textArt = pf.figlet_format(Text)
print("n", textArt)
elif(i%9 == 0):
textArt = pf.figlet_format(Text, font="xsbook")
print(textArt)
elif(i%5==0):
F = Figlet(font=random.choice(dataList))
textArt = colored(F.renderText(message), random.choice(colorList))
print("n", textArt)
elif(i%8==0):
F = Figlet(font=random.choice(dataList))
textArt = colored(F.renderText(Text), random.choice(colorList))
print("n", textArt)
elif(i%7==0):
textArt = pf.figlet_format(Text, font=random.choice(dataList))
print("n", textArt)
elif(i%4==0):
textArt = pf.figlet_format(reverseText, direction = "right-to-left")
print("n", textArt)
else:
print("")
time.sleep(random.choice(timeInterval))
#==================================
Output
Summary
In this article, we explored the idea of wishing someone Happy New Year 2025 in Python. Here, we create two Python programs.
The first program uses loops and random numbers to print fun new year messages with emojis and text. The second program uses the āpyfigletā and ātermcolorā modules to display a āHappy New Year 2025ā message with the personās name in ASCII text form on the Terminal or Command Prompt.
If you want more Python awesomeness, Check out our Cool Python Programs page! Below are a few instances to spark your interest.
- Say I Love You in Python Code
- Communicate with Your Friends Secretly using Python
- Draw the Sketch of Lionel Messi using a Python Program
- Create a Time Wasting Websites Blocker using Python
Happy New Year!