Study resource
Dictionaries study guide
Study Dictionaries with curriculum-aligned Study Guide resources, practice links, and exam-focused support.
At a glance
study guide
Resource type
Topic
Dictionaries
Study guide overview
Deeper Study Guide: Applying Dictionaries to Word Information Retrieval
Use this guide to connect the key–value model of a dictionary to a worked word-count representation, explain the effect of ignoring letter case, and justify retrieval results precisely.
Core model
Start with the definition: a dictionary is a collection of key–value pairs in which the value is accessed via the associated key. In an information-retrieval example, a word can be used as the key and information about that word can be stored as the value. In the supplied example, the value is the number of occurrences of the word in the document.
Consider the document:
text The green, green grass growsTo reason about its dictionary representation, identify the words, ignore letter case, and count occurrences.
Thebecomesthe;greenoccurs twice;grassoccurs once; andgrowsoccurs once. The resulting dictionary is:text {"grass": 1, "green": 2, "grows": 1, "the": 1}The important reasoning is not the displayed order of the pairs. The retrieval meaning comes from the association between each key and its value. A lookup using the key
"green"retrieves2, because the word occurs twice. A lookup using"the"retrieves1, because the case-normalised word occurs once.Worked application in Python
```python word_counts = {"grass": 1, "green": 2, "grows": 1, "the": 1}
print(word_counts["green"]) # 2 print(word_counts["grass"]) # 1 ```
The expression
word_counts["green"]uses the key"green"to access its associated value. It does not use a numerical position. In an exam explanation, state both parts: the key being supplied and the value retrieved.How to structure an exam answer
For a definition question, state that a dictionary is a collection of key–value pairs and that the value is accessed via its associated key. For a representation question, identify what the keys mean and what the values mean before presenting the pairs. For a lookup question, quote the key and follow the association to its value. For a counting question, explain that letter case is ignored and that repeated occurrences contribute to the associated count.
Self-check
- What is the key in the pair
"green": 2? - What does the value
2represent in the supplied document example? - Why is
Therepresented by the keythe? - What value should be retrieved by looking up
"grows"? - Why would representing the two occurrences of
greenas separate repeated entries fail to show the supplied dictionary representation?
Answers should use precise terminology: a key identifies the entry, the value is the associated information, and the value is accessed through the key. The expected retrieval values are
2forgreenand1forgrows. The lower-case key reflects the instruction to ignore letter case, and the singlegreenkey with value2records both occurrences.- What is the key in the pair
Ready to practise?
Choose your next step
Use the study guide for understanding, then switch into an active revision mode.
Related topics
