Python Code to Wish Happy Birthday

You’re a Python programmer and you want to impress your friend, cousin, special person, or anyone else with your Python skill. So, what you can do to impress them?

You can simply wish them Happy Birthday using Python. So, how to do that? Today I’m going to tell you that.

Happy Birthday Python Code

name = input("What's your name? ")
age = input("How old are you? ")
print("Happy Birthday, " + name + "!")
print("Congratulations on turning " + age + " years old today!")

Code Explanation

This Python code prompts the user for their name and age using the input() function and stores the user’s responses in the variables name and age.

Then, the program uses the print() function to output a happy birthday message to the user. The message includes the user’s name and age, which are inserted into the string using string concatenation.

Read More: How to create a phishing link 

The first print() statement outputs “Happy Birthday, ” followed by the user’s name, which is concatenated with the + operator.

The second print() statement outputs “Congratulations on turning ” followed by the user’s age and the string ” years old today!”. Again, the + operator is used to concatenate the different parts of the message together.

So, this is the code to wish anyone using Python code. I hope you love this article and you learn something new by reading this article. If you face any problems then tell me in the comment section.

What is your reaction?

In Love
Not Sure

Leave a reply

Your email address will not be published. Required fields are marked *