What if you could find any piece of information instantly, no matter how big your data is?
Why Dictionaries and key-value pairs in Intro to Computing? - Purpose & Use Cases
Imagine you have a big phone book where you want to find a friend's phone number. Without any order, you have to flip through every page until you find their name.
This manual search is slow and tiring. You might miss the name or get the wrong number. It's easy to make mistakes and waste time.
Dictionaries store data as pairs: a key (like a name) and a value (like a phone number). This lets you find any value quickly by looking up its key, just like using an index.
names = ['Alice', 'Bob', 'Carol'] numbers = ['123', '456', '789'] # To find Bob's number, search names list for 'Bob' and get number at same position
contacts = {'Alice': '123', 'Bob': '456', 'Carol': '789'}
# To find Bob's number, just do contacts['Bob']It makes finding, adding, or changing information fast and easy, even with lots of data.
Online stores use dictionaries to quickly find product prices by product ID, so you get instant results when shopping.
Dictionaries pair keys with values for quick lookups.
They save time and reduce errors compared to searching lists.
They help organize data like contacts, settings, or inventory efficiently.