Notes
Introduction
Python dictionaries are one of the most powerful and flexible data structures available in
Python. They allow programmers to store data in key–value pairs, making it easy to
organize and retrieve information efficiently.
Unlike lists or tuples that store elements in a sequence, dictionaries store data using unique
keys. Each key is associated with a specific value, allowing fast lookup and efficient data
access.
Dictionaries are widely used in real-world applications such as database records,
configuration settings, and data processing systems because they provide a structured way
to represent relationships between data.
Definition
A Python dictionary is an unordered collection of key–value pairs. Each key acts as an
identifier used to access its corresponding value.
Dictionaries are created using curly braces {} where each element consists of a key and a
value separated by a colon.
For example: student = {'name':'Rahul','age':21,'course':'Computer Science'}.
Key Characteristics of Dictionaries
Dictionaries store data in key–value format.
Keys must be unique within a dictionary.
Values can be of any data type including numbers, strings, lists, or even other dictionaries.
Dictionaries are mutable, meaning elements can be added, removed, or modified after
creation.
Dictionaries provide very fast data retrieval using keys.
Creating Dictionaries in Python
Dictionaries can be created using curly braces with key–value pairs separated by commas.
Example: employee = {'id':101,'name':'Amit','department':'IT'}.