Wish Happy New Year 2025 in Python

happy new year 2024 in python

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

Output of the Program

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.

Happy New Year!

Share your love
Subhankar Rakshit
Subhankar Rakshit

Hey there! Iā€™m Subhankar Rakshit, the brains behind PySeek. Iā€™m a Post Graduate in Computer Science. PySeek is where I channel my love for Python programming and share it with the world through engaging and informative blogs.

Articles:Ā 194