CodingNic

Data Structures

Data Structures in Real Projects

Data Structures 28 min read

Data Structures in Real Projects

Data Structures in Real Projects

Learning lists, tuples, dictionaries, and sets is important.

But the real power comes when you use them to solve real problems.

In this lesson, you will see how data structures are used in practical beginner projects.

Why This Lesson Matters

Real programs need to store, update, search, and organize data.

Data structures make this possible.

Project 1: Contact List

Use a list to store names.

python
contacts = ["Tom", "Sara", "Mike"]

for contact in contacts:
    print(contact)

Output

text
Tom
Sara
Mike

Why a List?

Because you need many names in one place.

Project 2: Product Information

Use a dictionary to store details.

python
product = {
    "name": "Laptop",
    "price": 900,
    "stock": 5
}

print(product["name"])
print(product["price"])

Output

text
Laptop
900

Why a Dictionary?

Because each value has a label.

Project 3: Unique Tags

Use a set to remove duplicates.

python
tags = {"python", "coding", "python", "learn"}
print(tags)

Output

text
{'python', 'coding', 'learn'}

Why a Set?

Because only unique values are needed.

Project 4: Fixed Coordinates

Use a tuple for values that should not change.

python
location = (40.7, -74.0)
print(location)

Output

text
(40.7, -74.0)

Why a Tuple?

Because coordinates should stay fixed.

Project 5: Student Records

Use a list of dictionaries.

python
students = [
    {"name": "Tom", "score": 85},
    {"name": "Sara", "score": 92}
]

for student in students:
    print(student["name"], student["score"])

Output

text
Tom 85
Sara 92

Why Nested Data?

Because each student has multiple details, and there are many students.

Project 6: Shopping Cart

Use a list of dictionaries.

python
cart = [
    {"name": "Book", "price": 10},
    {"name": "Pen", "price": 2}
]

total = 0

for item in cart:
    total += item["price"]

print(total)

Output

text
12

Why This Works

The list stores many products.

Each dictionary stores details for one product.

Choosing the Right Structure

Use:

  • List → many items
  • Tuple → fixed values
  • Dictionary → labeled data
  • Set → unique values

Code Along

python
movies = [
    {"title": "Inception", "year": 2010},
    {"title": "Avatar", "year": 2009}
]

for movie in movies:
    print(movie["title"])

Output

text
Inception
Avatar

Mini Challenge

Build a simple store.

Steps:

  • Create a list of dictionaries with 2 products
  • Each product should have:
    name, price
  • Print each product name
  • Add all prices
  • Print the total

Expected output:

text
Book
Pen
12

Real World Use Case

Apps, websites, dashboards, stores, and games all depend on data structures to manage information.

Quiz

  1. Which structure stores unique values?
  2. Which structure uses key-value pairs?
  3. Which structure is best for fixed data?
  4. Why use nested data?

Assignment

Create a student records program using a list of dictionaries. Print each student name and score.

Summary

You learned how data structures are used in real projects and how to choose the right one for different problems.