- A Dictionary Example
- What You Should See
- What Dictionaries Can Do
- Study Drills
- Common Student Questions
What Dictionaries Can Do
A dictionary is another example of a data structure, and, like a list, it is one of the most commonly used data structures in programming. A dictionary is used to map or associate things you want to store to keys you need to get them. Again, programmers donāt use a term like ādictionaryā for something that doesnāt work like an actual dictionary full of words, so letās use that as our real world example.
Letās say you want to find out what the word āhonorificabilitudinitatibusā means. Today you would simply copy-paste that word into a search engine and then find out the answer, and we could say a search engine is like a really huge super complex version of the Oxford English Dictionary (OED). Before search engines what you would do is this:
Go to your library and get āthe dictionary.ā Letās say itās the OED.
You know āhonorificabilitudinitatibusā starts with the letter āHā so you look on the side of the book for the little tab that has āHā on it.
Skim the pages until you are close to where āhonā starts.
Skim a few more pages until you find āhonorificabilitudinitatibusā or hit the beginning of the āhpā words and realize this word isnāt in the OED.
Once you find the entry, you read the definition to figure out what it means.
This process is nearly exactly the way a dict works, and you are basically āmappingā the word āhonorificabilitudinitatibusā to its definition. A dict in Python is just like a dictionary in the real world such as the OED.