Minu's Games logo
MINU'S ROBOTICS

A Minu's Games EdTech Lab

← Code & Cognition
Day 11 of 30Logic & Data Structures

🗂️Dictionaries

🎯 Today's objective

Store labelled data as key → value pairs.

📖 Key concepts

  • Dicts map keys to values: {"name": "Minu"}
  • Access with d["key"]
  • .get(), .keys(), .values(), .items()
  • Keys are unique

💻 Try this code

student = {"name": "Riya", "age": 13, "marks": 91}
print(student["name"], "scored", student["marks"])
student["grade"] = "A"
for k, v in student.items():
    print(k, "=", v)

👥 Learn it your way

🧒 Young Explorers

A dictionary is a real dictionary — look up a word (key) to get its meaning (value).

Your task

Make a dict of 3 friends → favourite colour, then print each "X likes Y".

💼 Professionals

Dicts are hash maps (O(1) lookup); use .get(key, default) to avoid KeyErrors.

Your task

Count word frequency in a sentence using a dict (the classic bag-of-words).

🤖 AI connection

Features and labels are stored as key→value. Word-frequency dicts ("bag of words") are a real, simple way text becomes numbers for AI.

✅ Quick check

How do you safely read a possibly-missing key?

d.get(key, default)

Can two keys be identical?

No — keys are unique.