Python Dictionary Deep Dive Quiz Quiz

  1. Dictionary Keys Method

    Which method returns a list of all keys in a Python dictionary?

    1. all_keys()
    2. keys()
    3. getKeyList()
    4. listKeys()
    5. KeyList()
  2. Dictionary Mutability

    Are Python dictionaries mutable objects, allowing for changes after creation?

    1. No, dictionaries are immutable.
    2. Only the keys are mutable.
    3. Only the values are mutable.
    4. Yes, dictionaries are mutable.
    5. Dictionaries are mutable, but only when initially defined.
  3. Dictionary Length

    Which function can be used to determine the number of key-value pairs in a dictionary?

    1. size()
    2. length()
    3. count()
    4. len()
    5. sizeof()
  4. Dictionary Item Removal

    Which method removes and returns an arbitrary key-value pair from a dictionary?

    1. remove()
    2. delete()
    3. pop()
    4. popitem()
    5. clear()
  5. Dictionary Clearing

    What method removes all items from a dictionary, leaving it empty?

    1. remove_all()
    2. flush()
    3. clear()
    4. empty()
    5. removeAll()
  6. Nested Dictionaries

    How can you access a value within a nested dictionary, assuming the structure is two levels deep?

    1. dict[key1, key2]
    2. dict.key1.key2
    3. dict[key1][key2]
    4. dict.get(key1, key2)
    5. dict(key1, key2)
  7. Sorting Dictionaries

    What function should be used to sort a dictionary?

    1. order()
    2. sort()
    3. sorted()
    4. arrange()
    5. reorder()
  8. Dictionary Views Method

    Which method returns a list consisting of key and value tuples?

    1. tuple()
    2. pairs()
    3. lists()
    4. items()
    5. dictionaryitems()
  9. Dictionary Existence Check

    How can you check if a specific key exists in a dictionary?

    1. Using a try-except block with KeyError
    2. Using the 'exists' keyword
    3. Using the 'contains' method
    4. Using the 'if' statement with the 'in' operator
    5. Using the 'has_key' method
  10. Merging Dictionaries

    What operator, available in Python 3.9 and later, can be used to merge two dictionaries?

    1. +
    2. *
    3. |
    4. u0026
    5. ^