Step 1: Define Dictionary.
A dictionary in Python is a data structure used to store data in key–value pairs. Each key is associated with a value, and keys must be unique within the dictionary.
Dictionaries are unordered collections and are written using curly braces
{}.
Step 2: Creating a Dictionary.
A dictionary can be created by assigning key–value pairs inside curly braces.
Example:
student = {"name":"Rahul", "age":20, "marks":85}
Here
name,
age, and
marks are keys and their associated values are Rahul, 20, and 85.
Step 3: Accessing Dictionary Items.
Dictionary values can be accessed using their keys.
Example:
print(student["name"])
This prints the value associated with the key
name.
Step 4: Finding the Length of a Dictionary.
The length of a dictionary can be determined using the
len() function.
Example:
len(student)
This returns the total number of key–value pairs in the dictionary.
Step 5: Conclusion.
Thus dictionaries store data in key–value pairs and allow efficient data retrieval using keys.