Lesson 4.2.7.1
4.2.7.1 Dictionaries and key-value pairs Quiz: AQA Computer Science, Unit 2
20 questions
In partnership with Revision Ninja
Lesson 4.2.7.1, Dictionaries and key-value pairs: 20 multiple choice questions for the AQA Computer Science (7517), Unit 2: Fundamentals of data structures, written with Revision Ninja.
Host it live on the board and students join with a game code on their own devices, or revise alone with Free Play. The answers are revealed in the game.
The 20 questions
-
What data structure consists of a collection of key-value pairs?
- Binary tree
- Queue
- Stack
- Dictionary
-
In a dictionary data structure, which component of each entry must be unique?
- Pointer
- Index
- Value
- Key
-
Which Python expression creates an empty dictionary?
- []
- ()
- <>
- {}
-
In an information retrieval dictionary built from a text document, what does each key represent?
- A word
- A line number
- A word count
- A character index
-
Which Python expression retrieves the value associated with key k in dictionary d?
- d.k
- d->k
- d[k]
- d(k)
-
In the dictionary {'grass': 1, 'green': 2, 'grows': 1}, what value is mapped to 'green'?
- 0
- 1
- 2
- 3
-
Which technique allows dictionaries to perform direct value lookups using keys?
- Traversal
- Sorting
- Linear searching
- Hashing
-
A dictionary d holds {'apple': 3, 'pear': 5}. After d['apple'] = d['apple'] + 1, what is d['apple']?
- 5
- 8
- 3
- 4
-
A word-count dictionary is built from the text 'The cat sat on the mat', ignoring letter case. What is the count stored for 'the'?
- 2
- 3
- 6
- 1
-
Given dictionary d = {'a': 1, 'b': 2}, what is len(d) after executing d['c'] = 3?
- 4
- 1
- 3
- 2
-
Dictionary scores = {'Ali': 55, 'Bea': 72, 'Cal': 61}. What does max(scores, key=scores.get) return?
- 'Cal'
- 72
- 'Ali'
- 'Bea'
-
Which statement removes the key 'pear' from dictionary d in Python?
- d.delete(pear)
- d.remove('pear')
- d['pear'].clear()
- del d['pear']
-
Using a list of key-value pairs instead of a dictionary, what is the worst-case number of key comparisons needed to find one key among 1000 entries?
- 500
- 1000
- 1
- 10
-
If word counts ignore case, what value maps to key 'the' for 'The cat and the hat'?
- 2
- 3
- 1
- 0
-
Why are student IDs preferred over student names as keys in a dictionary database?
- IDs use memory
- IDs are unique
- Names are shorter
- Names are unique
-
Given d = {'x': [1, 2], 'y': [3]}, what is d['x'] after executing d['x'].append(4)?
- [1, 2, 3, 4]
- [1, 2]
- [1, 2, 4]
- [4]
-
Dictionary lookup in Python is typically which order of complexity on average?
- Exponential time, O(2^n)
- Linear time, O(n)
- Logarithmic time, O(log n)
- Constant time, O(1)
-
What main advantage does a dictionary offer over a list when representing a sparse vector?
- Faster sorting
- Prevents errors
- Saves memory
- Guarantees order
-
For dictionary d = {'a': 1, 'b': 2, 'a': 5}, what value is stored at key 'a'?
- 1
- 2
- 6
- 5
-
When representing a vector as a dictionary, what do the keys typically represent?
- Vector indices
- Coordinate angles
- Vector magnitudes
- Scalar multipliers
Related quizzes
- Data structures and abstract data types Quiz · 4.2.1.1 · 20 questions
- Single- and multi-dimensional arrays Quiz · 4.2.1.2 · 20 questions
- Reading and writing text and binary files Quiz · 4.2.1.3 · 20 questions
- Linear, circular and priority queues Quiz · 4.2.2.1 · 20 questions
- Stack operations Quiz · 4.2.3.1 · 20 questions
- Graphs: weighted, directed and adjacency representations Quiz · 4.2.4.1 · 20 questions
- Trees and binary trees Quiz · 4.2.5.1 · 20 questions
- Hash tables, hashing and collisions Quiz · 4.2.6.1 · 20 questions
- Vectors and vector operations Quiz · 4.2.8.1 · 20 questions
- Data types Quiz · 4.1.1.1 · 20 questions