← Intro to programming with Python

Mini project: a pet profile card

Store facts in variables, print a card, then update it.

Start this lesson

Real programs keep information in variables and then show it in different ways. In this project you store facts about a pet, print a profile card, and then celebrate a birthday by updating one variable. Notice how the card text never has to be retyped: the variables do the work.

pet_name = "Pepper"
species = "rabbit"
age = 2
print("Name:", pet_name)
print("Species:", species)
print("Age:", age)

If Pepper turns 3, you only change age, and every line that uses it shows the new value.

Common mistake: changing the variable AFTER printing and expecting the earlier line to update. A print shows the value at the moment it runs.