Python: Project: Business Card Mgmt
Last updated: 2026-11-12
This is the capstone project for Phase 2. All the knowledge from previous lessons — lists, dictionaries, comprehensions, string methods — will be used to build a real, usable command-line business card management system. Completing this project means you've truly mastered Python's container core concepts.
1. Project Requirements
We will build a "Business Card Manager" that runs in the terminal and supports the following features:
1. Add a card — enter name, phone, email
2. Display all cards — list them in table format
3. Search cards — search by name (supports fuzzy search)
4. Modify a card — update information by name
5. Delete a card — delete by name
6. Statistics — show total count, email domain statistics
7. Exit the program
Data is stored using list + dictionary: all cards in a list, each card as a dictionary.
2. Data Structure Design
▶ Example: Business Card Data Structure
▶ Try it YourselfOutput:
# Executed successfully
3. Complete Code
Save this file as card_manager.py and run it directly:
▶ Example: Business Card Management System
▶ Try it YourselfOutput:
\n
Business Card Management System
=
1. Add Card
2. List All Cards
Code design approach: Each feature is implemented as an independent function. The main program uses a while loop + if-elif for dispatching. This makes the code structure clear — adding a new feature requires only a new function and an elif branch.
4. Sample Run
Welcome to the Business Card Management System!
Enter the corresponding number to select a function.
===================================
Business Card Management System
===================================
1. Add Card
2. List All Cards
3. Search Cards
4. Modify Card
5. Delete Card
6. Statistics
7. Exit
===================================
Select option (1-7): 1
--- Add Card ---
Name: Zhang San
Phone: 13800138000
Email: zhangsan@example.com
Card for Zhang San added.
Select option (1-7): 2
--- All Cards ---
# Name Phone Email
──────────────────────────────────────────────────────
1 Zhang San 13800138000 zhangsan@example.com
Total: 1 card
5. Extension Suggestions
▶ Example: Card Search and Statistics (Difficulty ⭐⭐)
▶ Try it YourselfOutput:
Found 2 matching 'Alice':
Alice - 13800138000
Alice Chen - 13700137000
Email domain distribution:
example.com: 1
test.com: 1
work.com: 1
Duplicate phones: False
5. Extension Suggestions
After completing the project, try adding these features:
| Feature | Implementation Idea |
|---|---|
| Data persistence | Use json.dump() to save to a file, and json.load() to load on startup (file operations will be covered later) |
| Group management | Add a group field to cards (colleagues/friends/family), organize with a dictionary by group |
| Data import/export | Use join() to output CSV files that can be opened in Excel |
| Sorted display | Sort by name: sorted(cards, key=lambda c: c["name"]) |
| Batch delete | Accept multiple names separated by commas, loop through deletions |
❓ FAQ
json.dump(cards, open("data.json", "w")) to save to disk.in keyword. Is it case-sensitive?"Zhang" in "Zhang San" is True, but "zhang" in "Zhang" is False (case-sensitive). If you need case-insensitive search, convert to lowercase before comparing: keyword.lower() in card["name"].lower().📖 Summary
- The business card management system uses a list for all data and dictionaries for individual records — the most common data organization pattern
- Modular design: each feature is an independent function; the main program uses a loop for dispatching
enumerate()generates numbered list displays- List comprehensions implement fuzzy search
- The dictionary's
get()method is used for frequency counting - The project, though simple, covers all core Phase 2 concepts
📝 Exercises
-
Beginner (Difficulty: Star): Add a new feature to the card system — display cards sorted by name (using
sorted()with thekeyparameter). -
Intermediate (Difficulty: Star-Star): Add a "group management" feature to the card system. Add a
groupfield to each card ("colleagues," "friends," "family"), then implement a menu option to view cards by group. -
Advanced (Difficulty: Star-Star-Star): Write a "book management system" from scratch without referring to the code above. Features include: add book (title, author, year), display all, search by author, sort by year, count books by author. Use list + dictionary for storage, all running in the command line.