What you'll build
Ask the user four questions about themselves, then print a clean five-line profile card. Get comfortable with input, types, and conversions.
Requirements
The must-do parts. If any are missing, we'll ask you to take another pass.
- Ask the user for their name, city, favourite food, and year of birth using
input(). - Convert the year of birth into an integer with
int()and calculate their age (use2026 - year). - Print a profile card with at least five lines — name, city, favourite food, age, and a closing line.
- Add one comment in your code explaining what the conversion line does.
Bonus, if you're feeling brave
- Ask for height in metres (use
float()for the conversion) and add it to the card. - Make the card look nicer with a row of dashes above and below.
Examples
What your program should look like when it runs. Lines starting with $ are typed by you; the rest is your program.
Example run
$ python profile_card.py
Your name: Adwoa
Which city do you live in? Kumasi
Favourite food: jollof
Year you were born: 2002
------------------------------
Name: Adwoa
City: Kumasi
Favourite food: jollof
Age (in 2026): 24
Welcome to PySprout.
------------------------------Where to start
Copy this scaffold into a new file. You don't have to use it — it's just a friendly nudge.
profile_card.py
# Ask four questions, then print a profile card.
name = input("Your name: ")
city = input("Which city do you live in? ")
food = input("Favourite food: ")
year_text = input("Year you were born: ")
# TODO: turn year_text into an integer and calculate age
year = int(year_text)
age = 2026 - year
# TODO: print a clean, five-line card using all four answersHow we'll grade it
Four checks, four points. Three or above is passing — we'll ask you to revise anything we can't tick.
| Check | What we look for | Pt |
|---|---|---|
| It runs | Starts cleanly. Asks all four questions in order. | 1 |
| Uses inputs | Every printed line uses something the user actually typed. | 1 |
| Uses types right | Year is converted to int. The age math actually works. | 1 |
| Readable output | The card is easy to scan — no walls of text glued together. | 1 |