Test your understanding of Python dictionaries with these true/false questions. Practice key concepts like key-value pairs, dictionary methods, and data manipulation to strengthen your Python programming skills. Ideal for beginners and students preparing for exams or interviews.
✅ True – Dictionary keys must be hashable (immutable) types like strings, numbers, or tuples. This is because Python uses the key's hash value for quick lookups.
❌ False – Dictionaries only maintain insertion order in Python 3.7+. In earlier versions, dictionaries were unordered.
✅ True – While keys must be immutable, values can be any Python object - lists, dictionaries, functions, etc.
✅ True – Dictionaries can contain other dictionaries as values, allowing for complex nested data structures.
❌ False – The get() method returns None (or a specified default) if the key doesn't exist, unlike direct access with square brackets which raises KeyError.
❌ False – Lists are mutable and cannot be used as dictionary keys. However, you can use tuples as keys since they're immutable.
❌ False – update() merges the new dictionary into the existing one, adding new keys and updating values for existing keys.
❌ False – The in operator only checks for keys in a dictionary. To check for values, you need to use the values() method (value in my_dict.values()).
❌ False – Dictionary comprehensions can use any valid key-value pairs, not just numeric keys. For example: {str(x): x**2 for x in range(5)}
✅ True – Before Python 3.7 (when dictionaries became ordered), popitem() would remove an arbitrary item. Now it removes the last inserted item.
Tutorials, Roadmaps, Bootcamps & Visualization Projects