Day 1 ยท Day 1: Python Basics
Personal Information Card
Build a Python program that collects personal information from the user and displays it as a formatted card.
Requirements
1. Collect: full name, age, city, occupation, hobby
2. Calculate birth year from age
3. Display formatted information card
4. Add a simple border design
2. Calculate birth year from age
3. Display formatted information card
4. Add a simple border design
import datetime
print("=== Personal Information Card ===")
print()
# Collect information
name = input("Full Name: ")
age = int(input("Age: "))
city = input("City: ")
occupation = input("Occupation: ")
hobby = input("Favorite Hobby: ")
# Calculate birth year
birth_year = datetime.datetime.now().year - age
# Display card
width = 44
print()
print("+" + "=" * width + "+")
print(f"| {'PERSONAL INFORMATION CARD':^{width}} |")
print("+" + "=" * width + "+")
print(f"| {'Name':<12}: {name:<{width-15}} |")
print(f"| {'Age':<12}: {age:<{width-15}} |")
print(f"| {'Birth Year':<12}: {birth_year:<{width-15}} |")
print(f"| {'City':<12}: {city:<{width-15}} |")
print(f"| {'Occupation':<12}: {occupation:<{width-15}} |")
print(f"| {'Hobby':<12}: {hobby:<{width-15}} |")
print("+" + "=" * width + "+")
โก 50 XP on completion
โ Back to Day 1
Your Code
Output
Click "Run" to execute your code...
โณ Loading Python runtime (first run may take a few seconds)...
Log in to mark this project complete and earn XP.