Dictionaries: names meet values
A dictionary stores key-value pairs. Think of a contact book where a name points to a phone number. Keys are unique. get() can provide a default when a key is missing.
हिन्दी में समझें
डिक्शनरी कुंजी और मान की जोड़ी रखती है, जैसे नाम से फोन नंबर ढूँढना। कुंजियाँ अनोखी होती हैं। get() गायब कुंजी के लिए वैकल्पिक मान दे सकता है।
अभ्यास: student के points 75 करें और प्रिंट करें।
Hinglish mein samjhein
Dictionary key-value pairs rakhti hai, jaise contact book. Har key unique hoti hai. get() se missing key ka default de sakte ho.
Practice: student points 75 karo aur points print karo.
A small Python example
student = {"name": "Asha", "points": 50}
print(student["name"])
print(student.get("city", "Unknown"))The browser playground runs real Python with Pyodide. Use sample variables instead of interactive input(). Browser package support differs from desktop Python.
Try this example in the Python playground →Practise this idea
Update student points to 75 and print the points.
Check answer & explanation
student = {"name": "Asha", "points": 50}
print(student["name"])
print(student.get("city", "Unknown"))
student["points"]=75
print(student["points"])Assigning student["points"] changes the value associated with that dictionary key. Printing it confirms the new value.
Stuck in the course? Choose Check answer for either the challenge or quiz. Read the explanation and continue to the next lesson at your own pace.
Check your understanding
What does a dictionary store?
Check the quiz answer
Key-value pairs
Keys identify their corresponding values.
References & corrections
Use the official Python documentation for full language rules. Read how these lessons are made and checked. Found a mistake? Report it to Excel Keys with this lesson URL and a reproducible example.