Python Dictionary
A dictionary maps a key to a value — a labelled lookup. person = {"name": "Asha", "age": 21}. person["name"] is Asha. Keys must be hashable (str, int, tuple of hashables). Values can be anything. You add, update, and delete pairs anytime. Loop with .items() when you need both key and value.
person["email"] on a missing key → KeyError. person.get("email", "-") returns "-". Prefer get when the key might miss. Dict is not a list — you don’t look up by 0, 1, 2 unless those numbers are actually keys.
Python Dictionary — output — 90 then 0. Asha exists. Neha missing → get default 0, no crash.
{ "Asha": 90, "Ravi": 85 }
│ │
key valueKeyError vs dict.get default.