Project 1 (Profile Card)

Build your first Python program using variables, input(), and type conversion.

Loading...
Project 1 (Profile Card)

The Task

Build a program that:

  • Asks the user for their name, age, city, and height in feet.
  • Prints a profile card with those details.
  • Shows the user’s age next year.

What You’ll Use

  • input() to take information from the user.
  • int() and float() to convert input into numbers.
  • Variables to store values.
  • print() to display the result.
  • \n to add spacing.
  • Comments to explain the code.

Expected Output

Enter your name: John
Enter your age: 27
Enter your city: Delhi
Enter your height in feet: 5.9
 
--- Profile Card ---
Name: John
Age: 27
City: Delhi
Height: 5.9 ft
Next year, you will be 28

Try It Yourself First

Give it a try before you scroll down.

Here’s a hint for each part:

  • input() always returns a string.
  • Age needs to be a whole number, so use int().
  • Height can have decimals, so use float().
  • To calculate next year’s age, add 1 to the age.

Solution

# Profile Card
 
name = input("Enter your name: ")
age = int(input("Enter your age: "))
city = input("Enter your city: ")
height = float(input("Enter your height in feet: "))
 
print("\n--- Profile Card ---")
print("Name:", name)
print("Age:", age)
print("City:", city)
print("Height:", height, "ft")
print("Next year, you will be", age + 1)

How It Works

  • name and city stay as strings, so no conversion is needed.
  • age is converted with int(), so we can add 1 to it later.
  • height is converted with float(), since it can have a decimal part.
  • \n at the start of "\n--- Profile Card ---" adds an empty line before the card.
  • age + 1 gives us next year’s age.

Common Mistake

If you forget int() when taking the age:

age = input("Enter your age: ")
print("Next year, you will be", age + 1)

Python raises an error because age is a string, while 1 is a number.

Challenges

If you want to go a little further, try these:

  • Add more pieces of information to the profile card.
  • Try changing the sep parameter in print() and see how it changes the output.

👉 Next tutorial: Python Strings