Lesson 1 · Python for Data Science
1 - Capstone Project in Python
Capstone projects help you bring together everything you have learned. Today we will build a simple contact manager. You will get to practice variables,…
- CoursePython for Data Science
- Lesson1 of 38
- Video15 min
- FormatJupyter notebook · 26 code cells
What you'll learn
Data
No separate download needed — the notebook creates or downloads everything it uses.
📓 Full notebook
Download .ipynb
Welcome to Your Capstone Python Project!#
Capstone projects help you bring together everything you have learned.
Today we will build a simple contact manager.
You will get to practice variables, lists, dictionaries, loops, functions, and a little bit of user input.
By the end, you should feel more confident using Python to solve real problems.
What Will the Contact Manager Do?#
Our contact manager will let you:
- Add new contacts
- View existing contacts
- Search for a contact
- Edit contact information
- Remove contacts
Think of it like a basic digital address book.
# Let us start by making an empty list to store our contacts
contacts = []
print("Contact list created.")
# Each contact will be a dictionary with keys for details
sample_contact = {
"name": "Eva Lima",
"phone": "555-1818",
"email": "eva@email.com"
}
print("Sample contact created:", sample_contact)
# Let us add this contact to our contact list
contacts.append(sample_contact)
print("Current contacts:", contacts)
# Let us ask the user to add a new contact now
name = input("Enter the contact's name: ")
phone = input("Enter the contact's phone: ")
email = input("Enter the contact's email: ")
new_contact = {
"name": name,
"phone": phone,
"email": email
}
contacts.append(new_contact)
print("Contact added:", new_contact)
# Let us print out all contacts so far
for contact in contacts:
print(contact)
# It is friendlier to print details one by one
for contact in contacts:
print("Name:", contact["name"])
print("Phone:", contact["phone"])
print("Email:", contact["email"])
print("-")
# Let us make a function to add contacts easily
def add_contact(name, phone, email):
contact = {
"name": name,
"phone": phone,
"email": email
}
contacts.append(contact)
print("Contact added:", contact)
# Let us use our new function to add another contact
add_contact("Jorge Allen", "555-3033", "jorge@email.com")
# Let us search for a contact by name
search_name = input("Enter the name to search for: ")
found = False
for contact in contacts:
if contact["name"].lower() == search_name.lower():
print("Found:", contact)
found = True
break
if not found:
print("No contact found with that name.")
# Let us practice editing a contact's details
edit_name = input("Enter the name of the contact to edit: ")
for contact in contacts:
if contact["name"].lower() == edit_name.lower():
new_phone = input("Enter the new phone: ")
new_email = input("Enter the new email: ")
contact["phone"] = new_phone
contact["email"] = new_email
print("Contact updated:", contact)
break
# Remove a contact by name
remove_name = input("Enter the name of the contact to remove: ")
for contact in contacts:
if contact["name"].lower() == remove_name.lower():
contacts.remove(contact)
print("Removed:", contact)
break
else:
print("Contact not found.")
# Let us count how many contacts we have
count = len(contacts)
print("You have", count, "contact(s) in your list.")
# Let us sort contacts by name for easier viewing
sorted_contacts = sorted(contacts, key=lambda c: c["name"].lower())
for contact in sorted_contacts:
print(contact["name"], '-', contact["phone"], '-', contact["email"])
# Let us practice finding contacts with a certain email provider
provider = input("Enter the email provider to search for (like 'email.com'): ")
for contact in contacts:
if provider in contact["email"]:
print(contact)
# Make a backup of the contacts list before making big changes
import copy
contacts_backup = copy.deepcopy(contacts)
print("Backup created. You are safe!")
Mini-Project: Let Us Make a Contact Menu!#
We will now combine what you know to build a menu system.
The menu will let you: add, view, search, edit, and remove contacts. All in one loop!
# Here is a simple menu in a loop
def show_contacts():
if not contacts:
print("No contacts to show.")
else:
for i, contact in enumerate(contacts):
print(f"{i+1}. {contact['name']} - {contact['phone']} - {contact['email']}")
while True:
print("\nMenu:")
print("1. Add contact")
print("2. View contacts")
print("3. Search contact")
print("4. Edit contact")
print("5. Remove contact")
print("6. Exit")
choice = input("Choose an option (1-6): ")
if choice == "1":
n = input("Name: ")
p = input("Phone: ")
e = input("Email: ")
add_contact(n, p, e)
elif choice == "2":
show_contacts()
elif choice == "3":
name = input("Name to search: ")
found = False
for contact in contacts:
if contact["name"].lower() == name.lower():
print(contact)
found = True
break
if not found:
print("Not found.")
elif choice == "4":
name = input("Name to edit: ")
for contact in contacts:
if contact["name"].lower() == name.lower():
phone = input("New phone: ")
email = input("New email: ")
contact["phone"] = phone
contact["email"] = email
print("Updated:", contact)
break
elif choice == "5":
name = input("Name to remove: ")
for contact in contacts:
if contact["name"].lower() == name.lower():
contacts.remove(contact)
print("Removed.")
break
else:
print("Not found.")
elif choice == "6":
print("Goodbye!")
break
else:
print("Try again.")
# Common error: forgetting to break or handle not found
name = "DoesNotExist"
for contact in contacts:
if contact["name"].lower() == name.lower():
print("Found:", contact)
break
else:
print("Not found.")
# Quick tip: add many contacts at once with a list of dictionaries
contacts.extend([
{"name": "Shawn Ray", "phone": "555-1261", "email": "shawn@email.com"},
{"name": "Angela Rowe", "phone": "555-4738", "email": "angela@email.com"},
])
print("Added two more contacts.")
# Challenge: Print only the names of contacts with a phone ending in '8'
for contact in contacts:
if contact["phone"].endswith("8"):
print(contact["name"])
Recap: What Did We Build?#
We put together everything from simple lists to full search and edit features.
Our contact manager can:
- Add new data
- Show and sort details
- Search and find people fast
- Update or remove mistakes
This is the core of many powerful real apps.
You Did It!#
If you found this project helpful, please:
- Like the video
- Leave a comment with your favorite part
- Subscribe for more lessons
- Share with friends who want to learn Python!
Thanks for learning Python with me!
Found this useful?
All lessons, notebooks and datasets here are free. If they helped you, a coffee keeps new lessons coming.



