🚀 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
Python Dictionaries: Key-Value Pairs & Data Storage
More Relevant Posts
-
🚀 Day 18 of My Python Learning Journey 🔍 Topic: Relational Operators in Python Today, I explored Relational Operators in Python — an essential concept used to compare values in programming. 📌 What are Relational Operators? Relational operators are used to compare two values. The result of the comparison is always True or False (Boolean output). 🔢 Types of Relational Operators in Python: 1️⃣ Equal To (==) Checks if two values are equal. a = 10 b = 10 print(a == b) # True 2️⃣ Not Equal To (!=) Checks if two values are not equal. print(a != b) # False 3️⃣ Greater Than (>) Checks if the left value is greater than the right value. print(a > 5) # True 4️⃣ Less Than (<) Checks if the left value is less than the right value. print(a < 5) # False 5️⃣ Greater Than or Equal To (>=) print(a >= 10) # True 6️⃣ Less Than or Equal To (<=) print(a <= 9) # False 💡 Why are Relational Operators Important? ✔ Used in decision-making statements (if, else) ✔ Used in loops (while, for) ✔ Helps in comparing values in real-world programs 🧠 Understanding relational operators is a key step toward mastering conditional statements and building logical programs. #Python #LearningJourney #Day18 #Coding #RelationalOperators #Programming #100DaysOfCode
To view or add a comment, sign in
-
-
Most beginners learn lists first. But dictionaries are where Python gets really powerful. I spent Day 4 of my journey going deep on Python Dictionaries — and I finally understand why every real-world Python project uses them constantly. Here's what clicked for me today 👇 A dictionary is just a way to store data with a label attached to it. Instead of remembering "index 0 is the name, index 1 is the age" — you just say: person["name"] → "Alice" person["age"] → 22 Clean. Readable. Obvious. And once you add these methods — it becomes a proper data structure: ✅ .get() — access values safely without crashing your code ✅ .update() — merge two dictionaries in one line ✅ .items() — loop through key-value pairs like a pro ✅ .setdefault() — set a value only if the key doesn't already exist ✅ Dict Comprehension — build entire dictionaries in a single line ✅ Nested Dicts — store complex real-world data like a database I made the cheat sheet above so I never have to Google these again. Save it if you're learning Python — it covers everything in one place. 🔖 What do you use dictionaries for most in your projects? Drop it in the comments 👇 Follow for more Madhesh B #Python #LearnToCode #PythonDictionaries #CodeNewbie #ProgrammingForBeginners #TechLearning #Madhesh B
To view or add a comment, sign in
-
-
🖥️ Day 1 of python journey What I learned today: Variables and the 4 core data types. Python has four fundamental types that appear in every program ever written: int — whole numbers. Every user ID, every age, every count, every loop index in every application is an integer. float — decimal numbers. Every price, every percentage, every measurement is a float. One important thing I learned: 0.1 + 0.2 in Python equals 0.30000000000000004, not 0.3. This is a floating-point precision issue that causes real bugs in financial applications. Professional developers use Python's Decimal module for money calculations. str — text. Every API response your application receives, every database field it reads, every message it displays is a string. bool — True or False. The entire logic of every program — every condition, every decision, every filter — is powered by boolean values. The insight that changed how I think about Python: input() always returns a string. Always. Even if the user types 100, Python gives you "100" — the text, not the number. If you try to do arithmetic on it without casting, you get a TypeError. The fix: int(input("Enter your age: ")) — convert the string to an integer immediately. This is the very first thing that trips up beginners. I learned it on Day 1. What I built today: A personal profile program that takes 5 inputs — name, age, city, is_employed, salary — stores them in correctly typed variables, and prints a formatted summary using f-strings: f"Name: {name} | Age: {age} | City: {city}" Simple? Yes. But this exact pattern — collect input, store in typed variables, format and display output — appears in every data entry form, every registration page, every dashboard in every Python application. #Day1#Python#PythonBasic#codewithharry#w3schools.com
To view or add a comment, sign in
-
Important Methods Every Python Developer Should Know While learning Object-Oriented Programming in Python, I realized that not all methods inside a class behave the same. Python provides three powerful types of methods that help us organize code better: ✔ Instance Methods ✔ Class Methods ✔ Static Methods Let’s understand them in a simple way 👇 --- 🔹 1. Instance Method Instance methods work with object data. • They access instance variables • The first parameter is always self Example: class Student: def __init__(self, name): self.name = name def display(self): print("Student Name:", self.name) s = Student("Vamshi") s.display() 📌 Instance methods are used when we want to work with object-specific data. --- 🔹 2. Class Method Class methods work with class variables instead of object variables. • Defined using @classmethod • The first parameter is cls Example: class Student: college = "BITS College" @classmethod def show_college(cls): print("College:", cls.college) Student.show_college() 📌 Class methods are useful when working with data shared by all objects. --- 🔹 3. Static Method Static methods are independent methods. • They don’t use self or cls • Defined using @staticmethod Example: class Calculator: @staticmethod def add(a, b): return a + b print(Calculator.add(5, 7)) 📌 Static methods are used for utility functions related to a class. Instance Method → Works with object data Class Method → Works with class data Static Method → Independent helper function Understanding these concepts helps us write clean, structured, and scalable Python code. 📚 Learning OOP step by step every day. #Python #OOP #PythonProgramming #CodingJourney #SoftwareDevelopment #LearnPython
To view or add a comment, sign in
-
-
Today, I started learning the basics of Python 🐍 🔹 **Comments in Python:** We use `#` for single-line comments. Example: `# This is a single-line comment` Python doesn’t have a dedicated syntax for multi-line comments, but we often use triple quotes (`""" """`) for multi-line strings, which can also serve as documentation. 🔹 **Variable Naming Conventions:** Valid variable names: `age_one`, `ageOne` Invalid variable names: `2age`, `age 2`, `age two` 🔹 **Multiple Variable Assignment:** We can assign multiple values in a single line: `x, y, z = "Apple", "Orange", "Car"` To print them: `print(x, y, z)` or individually: `print(x)` `print(y)` `print(z)` 🔹 **String Concatenation:** x = "Hello " y = "World" print(x + y) Output: **Hello World** Excited to continue learning Python step by step 🚀 #Python #Backend #AmlyAi #Hubino
To view or add a comment, sign in
-
Python Tip Every Beginner Should Know One concept that saves you from many bugs in Python Mutable vs Immutable Objects In Python, some objects can change after creation, while others cannot. 🔹 Immutable Objects (cannot change) Examples: int, float, string, tuple x = 10 x = x + 5 print(x) Here Python creates a new object instead of modifying the original one. Another example: name = "Python" name[0] = "J" # Error Strings are immutable, so their values cannot be changed. 🔹 Mutable Objects (can change) Examples: list, dictionary, set numbers = [1, 2, 3] numbers.append(4) print(numbers) Output: [1, 2, 3, 4] Here the same list object is modified. 💡 Why this matters? If you pass a list to a function, the original data can change. def add_item(lst): lst.append(100) data = [1, 2, 3] add_item(data) print(data) Output: [1, 2, 3, 100] Understanding this concept helps a lot in: ✔ Data Analysis ✔ Machine Learning ✔ Writing clean Python code 📌 Tip: If you want to avoid modifying the original list: new_list = old_list.copy() Small Python concepts like this make a big difference in writing better code. If you're learning Python, remember this: Mutable → Can change Immutable → Cannot change If you're learning Python, mastering small concepts like this makes a big difference. #Python #PythonProgramming #Coding #DataScience #LearnPython #ProgrammingTips #DataAnalyst
To view or add a comment, sign in
-
🐍 Python Challenge — Day 6 🚀 📚 Lists & Tuples Lists and tuples store multiple values in one variable. 🔹 List in Python A List is an ordered collection used to store multiple items in a single variable. Lists can hold different data types such as numbers, strings, or even other lists. They are commonly used when working with collections of data like student names, marks, or tasks. Here’s a quick breakdown 👇 • Ordered collection of items • Mutable (can be changed after creation) • Defined using square brackets [] • Supports adding, removing, and modifying elements Example: my_list = [1, 2, 3, "Python"] ✅ Best when data needs modification. 🔹 Tuple in Python A Tuple is also an ordered collection that allows storing multiple values together. Tuples are useful for grouping related data into a single structure, such as coordinates, RGB color values, or fixed records. Here’s a quick breakdown 👇 • Ordered collection of items • Immutable (cannot be changed after creation) • Defined using parentheses () • Faster and safer for fixed data Example: my_tuple = (1, 2, 3, "Python") ✅ Best for constant data and protecting values from changes. 💻 Code: numbers = [1, 2, 3] print(numbers[0]) 🧩 Code Explanation (Concepts): • [] → List (mutable). • () → Tuple (immutable). • Indexing starts from 0. 🧠 Practice Questions: 1️⃣ Create a list of five numbers. 2️⃣ Access the last element of a list. 🔥 Small takeaway: Collections help manage data efficiently. #Python #Programming #LearningInPublic #DeveloperJourney #30DaysChallenge
To view or add a comment, sign in
-
-
🚀Day 8/30 30DaysofPython Dictionaries Today’s learning focused on one of the most important data structures in Python: Dictionaries. Dictionaries allow us to store data in key–value pairs, making it easy to organize and access information efficiently. This concept is widely used in real-world applications such as APIs, databases, JSON responses, and configuration management. Key concepts covered today: -Creating dictionaries using {} and dict() -Accessing values using keys -Checking dictionary length with len() -Adding and modifying key–value pairs -Safely retrieving values using .get() -Checking if a key exists using in -Removing items using pop(), popitem(), and del -Converting dictionaries to lists using .items() -Getting dictionary keys with .keys() and values with .values() -Copying dictionaries using .copy() -Clearing and deleting dictionaries One interesting takeaway is how dictionaries can store different data types, including lists and even other dictionaries (nested dictionaries), making them extremely flexible for structured data. Practice exercises included: -Creating and modifying dictionaries -Managing keys and values -Converting dictionaries into lists -Deleting items and entire dictionaries Every day of this challenge strengthens my Python fundamentals and problem-solving mindset. If you're on a similar learning journey in Python or software development, feel free to connect. Always happy to learn, share ideas, and grow together. On to Day 9 – Conditionals tomorrow. 🔥 #Python #30DaysOfPython #Programming #CodingJourney #SoftwareDevelopment #TechLearning #PythonDeveloper
To view or add a comment, sign in
-
-
🐍 Python List Methods – Quick Guide for Beginners Python lists are one of the most commonly used data structures. Understanding list methods helps you manipulate and manage data efficiently. Here are some essential Python List Methods with simple examples: 🔹 append() Adds an element to the end of the list. Example: [1,2,3].append(4) → [1,2,3,4] 🔹 insert() Inserts an element at a specific position. Example: [1,2,3].insert(1,10) → [1,10,2,3] 🔹 remove() Removes the first occurrence of a specified value. Example: [1,2,3].remove(2) → [1,3] 🔹 pop() Removes and returns the last element. Example: [1,2,3].pop() → 3 🔹 pop(index) Removes and returns the element at a given index. Example: [1,2,3].pop(0) → 1 🔹 count() Counts how many times a value appears. Example: [1,2,3,2].count(2) → 2 🔹 index() Returns the index of the first occurrence of a value. Example: [1,2,3].index(3) → 2 🔹 sort() Sorts the list in ascending order. Example: [3,1,2].sort() → [1,2,3] 🔹 reverse() Reverses the order of elements in the list. Example: [1,2,3].reverse() → [3,2,1] 🔹 copy() Creates a shallow copy of the list. Example: [1,2,3].copy() → [1,2,3] 🔹 clear() Removes all elements from the list. Example: [1,2,3].clear() → [] ✨ Tip: Mastering these list methods can significantly improve your efficiency when working with Python data structures. #Python #PythonProgramming #Coding #Programming #DataStructures #LearnPython #TechLearning
To view or add a comment, sign in
-
-
When I started learning Python, I used lists for almost everything. But as I progressed, I realized something important: Choosing the wrong data structure can make your code slower, messy, and harder to maintain. While writing this article, I researched and went deeper into understanding how Python data structures actually work behind the scenes — hashing, mutability, and memory behavior — and then tried to simplify those concepts into a beginner-friendly decision guide. 🧠 Choosing the Right Python Data Structure: List, Tuple, Set, or Dictionary In this blog, I explain: • When to use List vs Tuple • Why Sets are powerful for fast lookups • How Dictionaries power real-world systems • A simple decision framework to choose the right structure Writing this blog helped me strengthen both my Python fundamentals and my ability to explain technical concepts clearly. If you're starting your Python journey and want to understand not just what to use but why, this might save you hours of confusion. 🔗 Read here: https://lnkd.in/d2zYBfwi Would love your feedback! Innomatics Research Labs #Python #DataStructures #BeginnerFriendly #LearningInPublic #ArtificialIntelligence #CodingJourney #InnomaticsResearchLabs
To view or add a comment, sign in
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development