Python Dictionaries: Key-Value Pairs & Data Storage

🚀 Day 11 of My Python Learning Journey – Understanding Dictionaries 🗂️🐍 Today, I learned about one of the most powerful data types in Python – Dictionary. 📌 What is a Dictionary in Python? A dictionary is a collection of key-value pairs. It is used to store data values like a map. 👉 Dictionaries are: ✅ Mutable (we can change values) ✅ Unordered (before Python 3.7 it was not guaranteed ordered) ✅ Indexed by keys ❌ Do not allow duplicate keys 🧠 Syntax of Dictionary my_dict = { "name": "Vani", "age": 22, "course": "Python" } Here: "name", "age", "course" → Keys "Vani", 22, "Python" → Values 🔹 Accessing Values: print(my_dict["name"]) Output: Vani 🔹 Adding or Updating Values: my_dict["age"] = 23 # Updating my_dict["city"] = "Hyderabad" # Adding 🔹 Removing Items: my_dict.pop("course") ✨ Why Dictionaries Are Important? ✔️ Fast data lookup ✔️ Used in APIs & JSON ✔️ Useful for storing structured data ✔️ Widely used in real-world applications 💡 Real-Life Example student = { "roll_no": 101, "name": "Vani", "marks": 95 } Dictionaries help in organizing structured data clearly and efficiently. 🔥 Key Takeaway If you want to connect a value with a unique key, use a Dictionary in Python. 📅 Day 11 Complete! Learning step by step and building consistency 💪 #Python #100DaysOfCode #LearningJourney #Coding #Dictionary #PythonBasics

  • graphical user interface

To view or add a comment, sign in

Explore content categories