Wish Happy New Year 2023 in Python

Happy New Year in Python

Introduction

A new year brings lots of fun, many promises, a career goal, new hope, and so many things. The idea came to mind to wish Happy New Year in a different style, like a programmer.

I developed two Python Programs to print Happy New Year on the Terminal or Command Prompt. The First Program is pretty simple. It will print Happy New Year Message in text form with different emojis. 

The Second Program (Program 2)👇 is quite interesting. It will print the message "Happy New Year" along with the name of the upcoming/current year (in this case, 2023) as a random type of ASCII text. Trust me, it will look more sophisticated.

Program 1


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 2022🎉')
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

Program 2

Before copying the code below, take a break here and read it carefully. The first program does not require any third-party modules to run but, this program uses two third party modules named pyfiglet and termcolor. You must install these two libraries on your system. Find the way below.

this is the output of the happy new year program
Output

Installation Process

Use 'pip3' instead of 'pip' for Linux.

☛Install pyfiglet: pip install pyfiglet==0.7
☛Install termcolor: pip install termcolor

The program randomly selects a font from 419 font types and does the same for color selection. There is a separate article on this topic where I describe how to print ASCII texts from scratch. Check this out from here: Wish Your Friends with Stylish Text in Python - pyfiglet, termcolor.

The program requires an additional file called "texts.txt" that I put right after the program. I would suggest you create a separate folder for this task and put two files ("happy-new-year.py", and "texts.txt") there.

happy-new-year.py


import time
import time
import random
import pyfiglet as pf
from pyfiglet import Figlet
from termcolor import colored

# The message
Text = "Happy New Year"
# Additional Message
Year = "2023"

# Reverse your given name
reverseText = Year[::-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(Year), 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))
#==================================

texts.txt


1943____
3-d
3x5
4x4_offr
5lineoblique
5x7
5x8
64f1____
6x10
6x9
a_zooloo
acrobatic
advenger
alligator
alligator2
alphabet
aquaplan
asc_____
ascii___
assalt_m
asslt__m
atc_____
atc_gran
avatar
b_m__200
banner
banner3
banner3-D
banner4
barbwire
basic
battle_s
battlesh
baz__bil
beer_pub
bell
big
bigchief
binary
block
brite
briteb
britebi
britei
broadway
bubble
bubble__
bubble_b
bulbhead
c1______
c2______
c_ascii_
c_consen
calgphy2
caligraphy
catwalk
caus_in_
char1___
char2___
char3___
char4___
charact1
charact2
charact3
charact4
charact5
charact6
characte
charset_
chartr
chartri
chunky
clb6x10
clb8x10
clb8x8
cli8x8
clr4x6
clr5x10
clr5x6
clr5x8
clr6x10
clr6x6
clr6x8
clr7x10
clr7x8
clr8x10
clr8x8
coil_cop
coinstak
colossal
com_sen_
computer
contessa
contrast
convoy__
cosmic
cosmike
cour
courb
courbi
couri
crawford
cricket
cursive
cyberlarge
cybermedium
cybersmall
d_dragon
dcs_bfmo
decimal
deep_str
demo_1__
demo_2__
demo_m__
devilish
diamond
digital
doh
doom
dotmatrix
double
drpepper
druid___
dwhistled
e__fist_
ebbs_1__
ebbs_2__
eca_____
eftichess
eftifont
eftipiti
eftirobot
eftitalic
eftiwall
eftiwater
epic
etcrvs__
f15_____
faces_of
fair_mea
fairligh
fantasy_
fbr12___
fbr1____
fbr2____
fbr_stri
fbr_tilt
fender
finalass
fireing_
flyn_sh
fourtops
fp1_____
fp2_____
fraktur
funky_dr
future_1
future_2
future_3
future_4
future_5
future_6
future_7
future_8
fuzzy
gauntlet
georgia11
ghost_bo
goofy
gothic
gothic__
graceful
gradient
graffiti
grand_pr
green_be
hades___
heavy_me
helv
helvb
helvbi
helvi
heroboti
hex
high_noo
hills___
hollywood
home_pak
house_of
hypa_bal
hyper___
inc_raw_
invita
isometric1
isometric2
isometric3
isometric4
italic
italics_
ivrit
jazmine
jerusalem
joust___
katakana
kban
kgames_i
kik_star
krak_out
larry3d
lazy_jon
lcd
lean
letter_w
letters
letterw3
lexible_
linux
lockergnome
mad_nurs
madrid
magic_ma
marquee
master_o
maxfour
mayhem_d
mcg_____
mig_ally
mike
mini
mirror
mnemonic
modern__
morse
moscow
mshebrew210
nancyj
nancyj-fancy
nancyj-underlined
new_asci
nfi1____
nipples
notie_ca
npn_____
ntgreek
nvscript
o8
octal
odel_lak
ogre
ok_beer_
os2
outrun__
p_s_h_m_
p_skateb
pacos_pe
panther_
pawn_ins
pawp
peaks
pebbles
pepper
phonix__
platoon2
platoon_
pod_____
poison
puffy
pyramid
r2-d2___
rad_____
rad_phan
radical_
rainbow_
rally_s2
rally_sp
rampage_
rastan__
raw_recu
rci_____
rectangles
relief
relief2
rev
ripper!_
road_rai
rockbox_
rok_____
roman
roman___
rot13
rounded
rowancap
rozzo
runic
runyc
sans
sansb
sansbi
sansi
sblood
sbook
sbookb
sbookbi
sbooki
script
script__
serifcap
shadow
short
skate_ro
skateord
skateroc
sketch_s
slant
slide
slscript
sm______
small
smisome1
smkeyboard
smscript
smshadow
smslant
smtengwar
space_op
spc_demo
speed
stacey
stampatello
standard
star_war
starwars
stealth_
stellar
stencil1
stencil2
stop
straight
street_s
subteran
super_te
t__of_ap
tanja
tav1____
taxi____
tec1____
tec_7000
tecrvs__
tengwar
term
thick
thin
threepoint
ti_pan__
ticks
ticksslant
times
timesofl
tinker-toy
tomahawk
tombstone
top_duck
trashman
trek
triad_st
ts1_____
tsalagi
tsm_____
tsn_base
tty
ttyb
twin_cob
twopoint
type_set
ucf_fan_
ugalympi
unarmed_
univers
usa_____
usa_pq__
usaflag
utopia
utopiab
utopiabi
utopiai
vortron_
war_of_w
weird
whimsy
xbrite
xbriteb
xbritebi
xbritei
xchartr
xchartri
xcour
xcourb
xcourbi
xcouri
xhelv
xhelvb
xhelvbi
xhelvi
xsans
xsansb
xsansbi
xsansi
xsbook
xsbookb
xsbookbi
xsbooki
xtimes
xtty
xttyb
yie-ar__
yie_ar_k
z-pilot_
zig_zag_
zone7___

Output Video

Watch the entire video to know how the program actually works.

 

Summary

In this tutorial, we discovered the way to wish someone Happy New Year like a programmer. We have created two Python programs that print Happy New Year messages with the name of the upcoming/current year (in this case, 2023). Both programs are interesting but the second one looks more advanced.

Pick any of one or both as you like and wish your favorite one using this unique technique. I hope, you will enjoy it.

Thanks for reading!

PySeek

Subhankar Rakshit

Meet Subhankar Rakshit, a Computer Science postgraduate (M.Sc.) and the creator of PySeek. Subhankar is a programmer, specializes in Python language. With a several years of experience under his belt, he has developed a deep understanding of software development. He enjoys writing blogs on various topics related to Computer Science, Python Programming, and Software Development.

Post a Comment (0)
Previous Post Next Post