Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesHere are nine runnable Python birthday programs, from a one-line greeting to an optional turtle-drawn card. The first eight print in a terminal; the last opens a graphics window. Each example includes its matching output and the Python idea it demonstrates.
1. Print a simple birthday greeting
print("Happy Birthday!")
Output:
Happy Birthday!
print() displays fixed text in the terminal; this is the simplest version because the message is written directly in the program.
2. Add a name to the greeting
name = "Maya"
print("Happy Birthday, " + name + "!")
Output:
Happy Birthday, Maya!
The name variable stores text that you can change to personalize the greeting.
3. Ask for a name and age
name = input("What is the birthday person's name? ")
age = input("How old are they turning? ")
print("Happy Birthday, " + name + "! You are " + age + " today.")
Sample input: enter Maya at the first prompt and 12 at the second.
#1 Best Overall
Output:
What is the birthday person's name? Maya
How old are they turning? 12
Happy Birthday, Maya! You are 12 today.
input() reads what the user types as text, so the age is kept as a string here rather than converted to a number.
4. Use a function for a reusable greeting
def birthday_greeting(name):
print("Happy Birthday, " + name + "!")
print("I hope your day is wonderful.")
birthday_greeting("Maya")
Output:
Happy Birthday, Maya!
I hope your day is wonderful.
A function groups instructions under a name so you can call the same greeting again with another person’s name.
Rank #2
5. Repeat a birthday message with a loop
for _ in range(3):
print("Happy Birthday!")
Output:
Happy Birthday!
Happy Birthday!
Happy Birthday!
The for loop runs its indented instruction three times, avoiding three separate print() statements.
6. Format a personalized greeting
name = "Maya"
age = 12
print(f"Happy {age}th Birthday, {name}!")
Output:
Happy 12th Birthday, Maya!
An f-string inserts variable values inside a string. This example assumes an age where adding th gives the desired ordinal wording; English ordinals vary, so for other ages you may prefer to write the message without an ordinal suffix.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware match7. Print a multiline birthday message
message = """Happy Birthday, Maya!
Wishing you laughter and a great year ahead.
Enjoy your special day!"""
print(message)
Output:
Happy Birthday, Maya!
Wishing you laughter and a great year ahead.
Enjoy your special day!
Triple quotes let one string contain line breaks, so print() displays the message across multiple lines.
8. Make a text-art birthday card
print("+--------------------------+")
print("| HAPPY BIRTHDAY! |")
print("| Maya, enjoy! |")
print("+--------------------------+")
Output:
+--------------------------+
| HAPPY BIRTHDAY! |
| Maya, enjoy! |
+--------------------------+
This uses ordinary text characters to draw a simple card in the terminal; edit the text while keeping the borders aligned if you change the name.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.9. Draw a birthday card with Python turtle
This optional version opens a graphics window instead of printing a card in the terminal. Python’s turtle documentation describes turtle as a way for learners to get immediate, visible feedback while encountering programming concepts. The module is in Python’s standard library, but it relies on Tk interface support, which may be packaged separately on some Linux distributions and other platforms.
import turtle as t
screen = t.Screen()
screen.title("Birthday Card")
pen = t.Turtle()
pen.hideturtle()
pen.speed(3)
pen.penup()
pen.goto(-150, 30)
pen.pendown()
pen.color("purple")
pen.write("Happy Birthday!", font=("Arial", 20, "bold"))
pen.penup()
pen.goto(-90, -20)
pen.color("blue")
pen.write("Have a wonderful day!", font=("Arial", 14, "normal"))
screen.mainloop()
Visible result: a graphics window with “Happy Birthday!” and “Have a wonderful day!” written in it. Turtle coordinates position the text, while write() draws it; change the strings to personalize the card. The final screen.mainloop() keeps the window open until you close it.
Best Value
If turtle does not open
- If the error says
No module named '_tkinter', your Python installation may lack Tk support. Check the Tk package or Python build provided for your operating system. - Do not assume that
pip install turtleis the fix: turtle is part of the standard library, while the missing piece may be the platform’s Tk interface. - For a greeting that only needs text, use any of Programs 1–8 instead; they do not require a graphics window.
Python.org lists Python 3.14.8, released September 30, 2026. These examples use basic Python syntax; the turtle setup note matters only when running the graphics example.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




