Dictionaries and Related Operations
A dictionary stores data as key-value pairs, letting you look up a value quickly using a meaningful key instead of a numeric index.
Creating a Dictionary
student = {
"name": "Rahul",
"age": 22,
"course": "Data Science"
}
Accessing and Updating Values
print(student["name"])
student["age"] = 23
student["city"] = "Noida"
Common Dictionary Methods
print(student.keys())
print(student.values())
print(student.items())
print(student.get("email", "Not Provided"))
Looping Through a Dictionary
for key, value in student.items():
print(key, ":", value)
Coming Up
With Python's core data structures covered, the next topic shifts to writing your own reusable blocks of code with user defined functions.