I think dictionaries might be the first Python topic that actually feels like organizing real life. 🐍 Day 08 of my #30DaysOfPython journey was all about dictionaries, and this one felt especially useful because it is basically how Python stores meaningful information. A dictionary is an unordered, mutable key-value data type. You use a key to reach a value — simple, but powerful. Today I explored: 1. Creating dictionaries with dict() built-in function and {} 2. Storing different kinds of values like strings, numbers, lists, tuples, sets, and even another dictionary 3. Checking length with len() 4. Accessing values using key name in [] or get() method 5. Adding and modifying key-value pairs 6. Checking whether a key exists using in operator 7. Removing items with pop(key), popitem() (removes the last item), and del 8. Converting dictionary items with items() which returns a dict_item object that contains key-value pairs as tuples 9. Clearing a dictionary with clear() 10. Copying with copy() and avoids mutation 11. Getting all keys with keys() and values with values(). These will return views - dict_keys() and dict_values() What stood out to me today was how dictionaries make data feel searchable instead of just stored. That key-value structure makes them one of the most practical tools in Python when working with real information. One more day, one more topic, one more step toward thinking in Python instead of just reading Python. When did dictionaries finally stop feeling confusing for you — or are they still one of those topics that need a second look? Github Link - https://lnkd.in/ewzDyNyw #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
Rohit Tiwari’s Post
More Relevant Posts
-
Stop using + to join strings in Python! 🐍 When you are first learning Python, it is tempting to use the + operator to build strings. It looks like this: name = "Gemini" status = "coding" print("Hello, " + name + " is currently " + status + ".") The Problem? In Python, strings are immutable. Every time you use +, Python has to create a brand-new string in memory. If you are doing this inside a big loop, your code will slow down significantly. The Pro Way: f-strings (Fast & Clean) Since Python 3.6, f-strings are the gold standard. They are faster, more readable, and handle data types automatically. The 'Pro' way: print(f"Hello, {name} is currently {status}.") Why use f-strings? Speed: They are evaluated at runtime rather than constant concatenation. Readability: No more messy quotes and plus signs. Power: You can even run simple math or functions inside the curly braces: print(f"Next year is {2026 + 1}") Small changes in your syntax lead to big gains in performance. Are you still using + or have you made the switch to f-strings? Let’s talk Python tips in the comments! 👇 #Python #CodingTips #DataEngineering #SoftwareDevelopment #CleanCode #PythonProgramming
To view or add a comment, sign in
-
Python: sort() vs sorted() Have you ever had to pause for a second and think: “Do I need sort() or sorted() here?” 😅 This is the common Python confusions. Let’s clear it up. 🔹 list.sort() ◾ A method (belongs to list objects) ◾ Works only on lists ◾ Sorts the list in-place ◾ Changes the original list ◾ Returns None Example: numbers = [3, 1, 4, 2] numbers.sort() print(numbers) # [1, 2, 3, 4] 🔹 sorted() ◾ A function (built-in Python function) ◾ Returns a new sorted list ◾ Does NOT change the original ◾ Works on any iterable Example: numbers = [3, 1, 4, 2] new_numbers = sorted(numbers) print(new_numbers) # [1, 2, 3, 4] print(numbers) # [3, 1, 4, 2] The key difference: sort() → changes your original data sorted() → keeps your original data safe 💡 Quick way to remember: 👉 If you want to keep the original, use sorted() 👉 If you want to modify the list directly, use sort() #Python #Programming #LearnPython #DataScience #LearningJourney #WomenInTech
To view or add a comment, sign in
-
-
Day 12/365: Checking If a List Is a Palindrome in Python 🔁 Today I solved a classic problem in Python: checking whether a list is a palindrome or not — using the two‑pointer technique with a for-else loop. 🔍 How this works step by step: I start with a list l that has elements arranged symmetrically. To check if it’s a palindrome, I compare elements from both ends: l[0] with l[-1], l[1] with l[-2], and so on. I only need to go till the middle of the list: range(len(l)//2) Inside the loop: If any pair doesn’t match, I print "list is not palindrome" and use break to exit the loop early. The interesting part is the for-else: The else block runs only if the loop finishes without hitting a break. That means all pairs matched, so I print "list is palindrome". 💡 What I learned: How to use the two‑pointer technique to compare elements from start and end efficiently. How Python’s for-else works — the else is tied to the loop, not the if. Why we only need to iterate till the middle of the list for palindrome checking. How the same logic can be reused for: checking if a string is a palindrome, validating symmetric data in lists and arrays. Day 12 done ✅ 353 more to go. If you have ideas like: checking palindromes while ignoring cases/spaces in strings, handling mixed data types in lists, or checking palindromes in other data structures, drop them in the comments — I’d love to try them next. #100DaysOfCode #365DaysOfCode #Python #LogicBuilding #TwoPointers #Lists #CodingJourney #LearnInPublic #AspiringDeveloper
To view or add a comment, sign in
-
-
Hello there and welcome to this new section called: 'Learning Python with me'. Today, I will bring you one of the most basic commands, and we will create a name generator using Python. I am very excited to start this project and have you coming along with me! Scenario: We have a friend who has a beer company. He has everything: the product, the manufacturing, and the investment. But he is missing one single thing—the name of the company. He is struggling to think about it and asked us for help to create a name for him. We will use Python to generate two questions and combine them to create his beer company name! What will we use in Python: As you can see in the video, I am starting by leaving notes in Python. However, these notes cannot be left by themselves; they need to be preceded by a "#" symbol, which makes Python understand we are leaving comments instead of writing code. Variables: Variables are containers used to store data values. You create one by giving it a name and assigning a value using the "=" operator. Strings: Strings are sequences of text. In Python, they must be wrapped in either single quotes (' ') or double quotes (" "). Input: input() is a way to get information from the user. It allows the program to 'pause' and wait for you to type something into the console. So, as you can see, we are combining strings and inputs in the video. Why am I mentioning variables if I did not use them in the code? Because variables and strings tend to go together, so I could have used a variable to store and print the strings, something like this: result = ("The beer company name is: " + input("What is your favorite color?: ") + input("What is your favorite animal?: ")) print(result) This works exactly like the example in the video (you can test it). It's just that I put the print statement directly on the same line. As programmers, we want to save as much work as possible, so we keep everything clean and easy to read. I hope you enjoy it!" #Python #PythonProject #personalproject #DataScience #SideProject.
To view or add a comment, sign in
-
Built a simple calculator using Python 🧮 Recently completed the basics of: • Variables • User Input • Conditional Statements (if/elif/else) Applied these concepts to create this small project. Looking forward to building more as I continue learning Python 🚀 Here’s the code: ```python a = int(input("what is first value: ")) b = input("what you want to do: ") c = int(input("what is second value: ")) if b == "+": print("your result is", a + c) elif b == "-": print("your result is", a - c) elif b == "*": print("your result is", a * c) elif b == "/": print("your result is", a / c) ``` #Python #CodingJourney #BeginnerProject #LearningByDoing
To view or add a comment, sign in
-
Day 4 – Python: Files, Data Formats, Functional Tools & Recursion** The series continues with 15 programs covering practical file handling, structured data, functional programming concepts, and an introduction to recursion and decorators. **Focus areas for Day 4:** Working with the filesystem via `os` and `sys`, reading/writing `csv` and `json`, iteration tools like `enumerate` and `zip`, functional constructs `map`, `filter`, `lambda`, plus recursion fundamentals and a first look at decorators. **Day 4 program list:** | Concept | File | | --- | --- | | Filesystem basics | `01_os_basics.py` | | Cross-platform paths | `02_path_join.py` | | File modes: write vs append | `03_write_append_file.py` | | Line-by-line reading | `04_read_lines.py` | | CSV read/write | `05_csv_read_write.py` | | JSON read/write | `06_json_read_write.py` | | `enumerate()` and `zip()` | `07_enumerate_zip.py` | | `map()` and `filter()` | `08_map_filter.py` | | Lambda for sorting | `09_lambda_sort.py` | | Dictionary methods | `10_dict_methods.py` | | List methods | `11_list_methods.py` | | Recursion: factorial | `12_recursion_factorial.py` | | Recursion: Fibonacci | `13_recursion_fibonacci.py` | | Command-line arguments | `14_command_line_args.py` | | Decorator basics | `15_simple_decorator.py` | **How to use:** All scripts use only the Python standard library. Python 3 required. Run individually: `python 06_json_read_write.py` Run the full set: `python Day4Files.py` **Series progression:** Day 1 → Syntax, I/O, basic logic Day 2 → Functions, lists, dicts, file I/O Day 3 → Exceptions, modules, OOP basics Day 4 → File systems, data formats, functional tools, recursion This stage bridges the gap between writing scripts and working with real data. These are the tools you’ll use daily when automating tasks, processing files, or building CLI utilities. #Python #SoftwareEngineering #DataEngineering #Programming #FileIO #ComputerScience #FunctionalProgramming #Recursion #TechEducation #OpenSource #GitHub #PythonProgramming Threads Link:- https://lnkd.in/gVf8wrpY
To view or add a comment, sign in
-
🚀 #python #Ep 2: Understanding #Data Types in Python In Python, everything is an object, and every object has a data type. Data types define what kind of value a variable holds and what operations you can perform on it. 🔗 Code reference: https://lnkd.in/ei6STRqT 🧠 Why Data Types Matter? Prevent errors in your code Help Python understand how to store and process data Make your programs efficient and readable 📌 Common Python Data Types 🔢 Numeric Types int → Whole numbers (10, -5) float → Decimal numbers (3.14) complex → Complex numbers (2+3j) 📝 String (str) Used to store text Example: "Hello Python" ✅ Boolean (bool) Only two values: True or False 📦 Sequence Types list → Ordered & mutable → [1, 2, 3] tuple → Ordered & immutable → (1, 2, 3) 🗂️ Mapping Type dict → Key-value pairs → {"name": "Hari"} 🔁 Set Types set → Unordered & unique values → {1, 2, 3} 💡 Pro Tip Python is dynamically typed, meaning you don’t need to declare data types explicitly — Python figures it out at runtime 🔍 Example x = 10 # int y = 3.14 # float name = "Hari" # str is_active = True # bool 📣 Final Thought Mastering data types is the foundation of Python programming. Once you understand them, everything else becomes easier! #Python #Coding
To view or add a comment, sign in
-
-
DAY 2 – #LearningInPublic (Python Basics) 🧠 Today’s Focus: My First Calculation in Python ✅ Every programming journey starts with something small — today I wrote my first Python calculation using variables and addition. Here’s what I learned: 📌 Step 1: Create Variables I stored numbers inside variables: • a = 10 • b = 10 Variables act like containers that hold values. 📌 Step 2: Perform Calculation I added both variables: sum = a + b Python calculated the result and stored it in a new variable called sum. 📌 Step 3: Print Output Finally, I displayed the result using print(): Output: 20 Wow You have done your first calculation in Python 💡 Key Concepts Learned • Variables • Assignment operator (=) • Addition operator (+) • Storing results in variables • print() function • Running first Python program This may look simple, but this is the foundation of everything in Python: Data Science Machine Learning AI Automation Web Development Every advanced system starts with basic calculations like this. Small steps. Big journey ahead. 🚀 #LearningInPublic #Python #PythonBeginner #DataScience #AI #Programming #100DaysOfCode #DeveloperJourney #MachineLearning #AIEngineering
To view or add a comment, sign in
-
F-strings in Python — Not Just Cleaner. Fundamentally Better. Python has had three ways to format strings over its history. If you’ve only learned the language recently, you might not have encountered the older two — but you will, because they still appear in legacy codebases, documentation, and tutorials written before Python 3.6. The first was % formatting, borrowed from C: name = "Andres" print("Hello, %s. You have %d messages." % (name, 5)) It works. But the syntax is cryptic, the order of arguments is error-prone, and it becomes harder to read as soon as you add more than one variable. The second was .format(), introduced in Python 3.0: print("Hello, {}. You have {} messages.".format(name, 5)) An improvement — more explicit, more flexible. But the variables and the placeholders are still separated. To understand what goes where, your eyes have to travel back and forth across the line. Then Python 3.6 introduced f-strings: print(f"Hello, {name}. You have {5} messages.") The variable lives inside the string, exactly where it appears in the output. No positional arguments. No external references. The code reads the way the sentence reads. Beyond readability, f-strings also evaluate expressions directly inline — which means you can do this: hours = 7.5 print(f"Weekly total: {hours * 5} hours") No intermediate variable needed. And in terms of performance, f-strings are consistently faster than .format() because they are parsed closer to compile-time rather than evaluated fully at runtime. Knowing all three methods matters. Understanding why f-strings became the standard tells you something about how Python evolves — always toward clarity. #Python #PythonMOOC2026 #BackendDevelopment #SoftwareEngineering #LearningInPublic #UniversityOfHelsinki
To view or add a comment, sign in
-
-
Many Python I/O tutorials end at print() and open(). This one goes further. On PythonCodeCrack there's a full beginner tutorial on Python I/O that covers the ground many skip — not just how to use the tools, but why they work the way they do. What's inside: — stdin, stdout, and stderr: what they are, where they come from, and why Python didn't invent them — print() in full: sep, end, flush, and why flush=True doesn't mean your data is on disk — input() and why it always returns a string no matter what the user types — File modes r, w, a, and x — including why 'w' truncates before the first write, not during it — The three-layer CPython I/O stack (TextIOWrapper → BufferedWriter → FileIO) and how to inspect it live — PEP 393: why a single emoji in a 2 GB text file can force 4 bytes per character across the entire string — buffering=1 line-buffered mode for crash-safe log files — flush() vs os.fsync() — two entirely different operations that most tutorials treat as the same thing — Python 3.15 making UTF-8 the default on all platforms, and what that means for existing code — sys.__stdout__ vs sys.stdout, newline translation, file descriptors, and TOCTOU race conditions The tutorial includes interactive quizzes, spot-the-bug challenges, a code builder, predict-the-output exercises, a 15-question final exam, and a downloadable certificate of completion. https://lnkd.in/gbYPmYgv #Python #PythonProgramming #LearnPython #CodingEducation
To view or add a comment, sign in
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