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.

Host this setFree Play

The 20 questions

  1. What data structure consists of a collection of key-value pairs?

    • Binary tree
    • Queue
    • Stack
    • Dictionary
  2. In a dictionary data structure, which component of each entry must be unique?

    • Pointer
    • Index
    • Value
    • Key
  3. Which Python expression creates an empty dictionary?

    • []
    • ()
    • <>
    • {}
  4. 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
  5. Which Python expression retrieves the value associated with key k in dictionary d?

    • d.k
    • d->k
    • d[k]
    • d(k)
  6. In the dictionary {'grass': 1, 'green': 2, 'grows': 1}, what value is mapped to 'green'?

    • 0
    • 1
    • 2
    • 3
  7. Which technique allows dictionaries to perform direct value lookups using keys?

    • Traversal
    • Sorting
    • Linear searching
    • Hashing
  8. A dictionary d holds {'apple': 3, 'pear': 5}. After d['apple'] = d['apple'] + 1, what is d['apple']?

    • 5
    • 8
    • 3
    • 4
  9. 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
  10. Given dictionary d = {'a': 1, 'b': 2}, what is len(d) after executing d['c'] = 3?

    • 4
    • 1
    • 3
    • 2
  11. Dictionary scores = {'Ali': 55, 'Bea': 72, 'Cal': 61}. What does max(scores, key=scores.get) return?

    • 'Cal'
    • 72
    • 'Ali'
    • 'Bea'
  12. Which statement removes the key 'pear' from dictionary d in Python?

    • d.delete(pear)
    • d.remove('pear')
    • d['pear'].clear()
    • del d['pear']
  13. 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
  14. If word counts ignore case, what value maps to key 'the' for 'The cat and the hat'?

    • 2
    • 3
    • 1
    • 0
  15. 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
  16. 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]
  17. 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)
  18. What main advantage does a dictionary offer over a list when representing a sparse vector?

    • Faster sorting
    • Prevents errors
    • Saves memory
    • Guarantees order
  19. For dictionary d = {'a': 1, 'b': 2, 'a': 5}, what value is stored at key 'a'?

    • 1
    • 2
    • 6
    • 5
  20. When representing a vector as a dictionary, what do the keys typically represent?

    • Vector indices
    • Coordinate angles
    • Vector magnitudes
    • Scalar multipliers

All AQA Computer Science quizzes