Interview Question

What are dictionaries?

Dictionaries map unique hashable keys to values.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

A dictionary is a mutable mapping from hashable keys to values. • Keys are unique within a dictionary. • Dictionaries preserve insertion order. • Looking up a missing key with brackets raises KeyError.

💡 Simple Example

user = {'name': 'Maya', 'role': 'admin'} print(user['name'])

Output

Maya

⚡ Quick Revision

Dictionaries map unique hashable keys to values.