Day 10 focused on mastering Python for loops, the range() function, and utilizing the type() function to inspect data types. Key takeaways included iterating over sequences, using range(start, stop, step) for controlled iterations, and understanding that range() stop values are exclusive.range() Function: Generates a sequence of numbers, commonly used for looping a specific number of times. range(stop): 0 to stop-1 (e.g., range(5) is 0,1,2,3,4). range(start, stop): start to stop-1. range(start, stop, step): start to stop-1, incrementing by step. type() Function: Used to determine the data type of an object (e.g., type(5) returns <class 'int'>). Looping with len(): Often used to iterate through a list using indices: for i in range(len(list)): Codegnan #100dayscourse #learningpython #python #learning #functions
Mastering Python Loops with range() and type() Functions
More Relevant Posts
-
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
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
-
-
Here’s your Day 11 LinkedIn post continuing your Python journey 👇 --- 🚀 ✨ 𝐃𝐀𝐘 11: 𝐖𝐎𝐑𝐊𝐈𝐍𝐆 𝐖𝐈𝐓𝐇 𝐓𝐔𝐏𝐋𝐄𝐒 ✨ Today, I explored another useful data structure in Python — 💻 𝐓𝐮𝐩𝐥𝐞𝐬. 🔹 📘 𝐖𝐡𝐚𝐭 𝐀𝐫𝐞 𝐓𝐮𝐩𝐥𝐞𝐬? Tuples are similar to lists but are 𝐢𝐦𝐦𝐮𝐭𝐚𝐛𝐥𝐞 (𝐜𝐚𝐧𝐧𝐨𝐭 𝐛𝐞 𝐜𝐡𝐚𝐧𝐠𝐞𝐝) once created. 🔹 ⚙️ 𝐖𝐡𝐚𝐭 𝐈 𝐋𝐞𝐚𝐫𝐧𝐞𝐝 ✔️ Creating and accessing 𝐭𝐮𝐩𝐥𝐞𝐬 ✔️ 𝐢𝐧𝐝𝐞𝐱𝐢𝐧𝐠 & 𝐬𝐥𝐢𝐜𝐢𝐧𝐠 ✔️ Difference between 𝐥𝐢𝐬𝐭𝐬 vs 𝐭𝐮𝐩𝐥𝐞𝐬 🔹 🧠 𝐖𝐡𝐲 𝐈𝐭 𝐌𝐚𝐭𝐭𝐞𝐫𝐬 Tuples are useful when we need 𝐟𝐢𝐱𝐞𝐝 𝐝𝐚𝐭𝐚 and ensure data remains unchanged. 💡 𝐈𝐦𝐦𝐮𝐭𝐚𝐛𝐥𝐞 𝐝𝐚𝐭𝐚 = 𝐌𝐨𝐫𝐞 𝐫𝐞𝐥𝐢𝐚𝐛𝐥𝐞 𝐩𝐫𝐨𝐠𝐫𝐚𝐦𝐬! 💪 𝐆𝐚𝐢𝐧𝐢𝐧𝐠 𝐦𝐨𝐫𝐞 𝐜𝐥𝐚𝐫𝐢𝐭𝐲 on data structures! 🚀 𝐊𝐞𝐞𝐩 𝐥𝐞𝐚𝐫𝐧𝐢𝐧𝐠, 𝐤𝐞𝐞𝐩 𝐠𝐫𝐨𝐰𝐢𝐧𝐠! #Python #Day11 #CodingJourney #Tuples #DataStructures #LearningPython #Consistency🚀
To view or add a comment, sign in
-
-
𝐃𝐚𝐲 𝟏𝟏: 𝐒𝐭𝐨𝐩 𝐒𝐞𝐚𝐫𝐜𝐡𝐢𝐧𝐠, 𝐒𝐭𝐚𝐫𝐭 𝐅𝐢𝐧𝐝𝐢𝐧𝐠 I’ve noticed as I move deeper into Python, is that how we 𝐬𝐭𝐨𝐫𝐞 𝐝𝐚𝐭𝐚 is just as important as the focusing on the code logic. Up until now, I’ve been reaching for a 𝐋𝐢𝐬𝐭 for almost everything. It’s the go-to structure when you start. But as my data grows,I realized why that can be a trap. 👉 If you have 1,000 items, a List forces you to check every single one until you find a match. • With a 𝐃𝐢𝐜𝐭𝐢𝐨𝐧𝐚𝐫𝐲, I’m not just piling data into a box; I’m giving every piece of data a unique Key. 👉𝐓𝐡𝐞 𝐋𝐢𝐬𝐭 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 (𝐦𝐲𝐥𝐢𝐬𝐭) : Iterating through the stack until you hit "Bob." 👉𝐓𝐡𝐞 𝐃𝐢𝐜𝐭𝐢𝐨𝐧𝐚𝐫𝐲 𝐀𝐩𝐩𝐫𝐨𝐚𝐜𝐡 (𝐦𝐲𝐝𝐢𝐜𝐭) : Direct access via a unique Key. Instant results✅ A Dictionary is a completely different, and much more efficient, tool for the job. It’s a fundamental shift in how we handle data retrieval. #Python #30DaysOfCode #Day11 #LearningInPublic #SoftwareEngineering
To view or add a comment, sign in
-
-
Most Python beginners confuse variables, data types, and casting. Here's the clearest breakdown I know: A variable is just a label on a box: age = 25 name = "Tanvir" active = True Python has 4 core data types you'll use every day: 1. int → whole numbers (25, 100) 2. float → decimals (9.99, 3.14) 3. str → text ("hello", "42") 4. bool → True or False Type casting = converting one type to another. Python does it automatically sometimes (implicit): x = 5 + 2.0 # result is 7.0 (int + float = float) You do it manually when needed (explicit): int("42") # → 42 str(99) # → "99" float("3.14") # → 3.14 ⚠️ The gotcha: int("hello") # → ValueError! Only cast when the value is actually compatible. Understanding this saves hours of debugging type errors in real projects. What Python concept confused you the most as a beginner? Drop it below 👇 #Python #ProgrammingForBeginners #LearnPython #PythonTips #CodingBangladesh
To view or add a comment, sign in
-
Most Python beginners confuse variables, data types, and casting. Here's the clearest breakdown I know: A variable is just a label on a box: age = 25 name = "Tanvir" active = True Python has 4 core data types you'll use every day: 1. int → whole numbers (25, 100) 2. float → decimals (9.99, 3.14) 3. str → text ("hello", "42") 4. bool → True or False Type casting = converting one type to another. Python does it automatically sometimes (implicit): x = 5 + 2.0 # result is 7.0 (int + float = float) You do it manually when needed (explicit): int("42") # → 42 str(99) # → "99" float("3.14") # → 3.14 ⚠️ The gotcha: int("hello") # → ValueError! Only cast when the value is actually compatible. Understanding this saves hours of debugging type errors in real projects. What Python concept confused you the most as a beginner? Drop it below 👇 #Python #ProgrammingForBeginners #LearnPython #PythonTips #CodingBangladesh
To view or add a comment, sign in
-
Python Data Types — One Post Cheat Sheet Understanding data types is fundamental to writing efficient Python code. Here’s a quick overview: 🔢Numeric int → 10 float → 10.5 complex → 2+3j 🔤 String (str) Ordered & immutable Example: "Hello Python" 📋 List Ordered, mutable, allows duplicates Example: [10, 20, 30] 📦 Tuple Ordered, immutable Example: (10, 20, 30) 🔁 Set Unordered, no duplicates Example: {10, 20, 30} 📖 Dictionary Key–value pairs, mutable Example: {"name": "Maha", "age": 25} 🧠 Boolean True / False Used in conditions 🔍 Check Type type(variable) Choosing the right data type improves performance, readability, and data handling. #Python #DataTypes #PythonBasics #Programming #LearnPython #Coding #DataAnalytics #PythonForBeginners
To view or add a comment, sign in
-
-
🚀 Day 68 | Python Revision (Up to Recursion) Today I focused on revising all Python concepts up to recursion 📘 🔹 What I Revised: • Basics → variables, data types, input/output • Control statements → if-else, loops • Functions → user-defined functions, arguments • Built-in functions → len(), sum(), min(), max(), etc. • String methods → strip(), split(), replace(), join() • List & Dictionary operations • Lambda functions and functional programming basics • Recursion → factorial, list flattening 💡 Key Learning: • Revision helps in connecting all concepts together • Improved clarity on when to use loops vs recursion • Strengthened understanding of problem-solving approaches 🔥 Takeaway: 👉 Strong fundamentals come from consistent revision Consistency + Revision = Confidence 🚀 #Day68 #Python #Revision #Recursion #ProblemSolving #CodingJourney #10000Coders #PythonDeveloper #SravanKumarSir
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
-
-
Day 10 𝙄 𝙎𝙩𝙤𝙥𝙥𝙚𝙙 𝘾𝙤𝙪𝙣𝙩𝙞𝙣𝙜 𝙄𝙣𝙙𝙚𝙭𝙚𝙨 𝙞𝙣 𝙋𝙮𝙩𝙝𝙤𝙣 One thing I’ve been learning while programming in Python is how to move away from the "index-heavy" logic I used in other languages 👉🏻 Today, it’s all about 𝗟𝗶𝘀𝘁 𝗦𝗹𝗶𝗰𝗶𝗻𝗴 • Here ,we don't need manual counters or complex loops just to grab a piece of data. Slicing provides a clean, intuitive way to extract exactly what you need in a single line. • Instead of managing i and j variables or calculating len(list) - n, you use Python’s built-in [start:stop:step] logic. It stops those annoying errors and makes the code’s intent immediately clear to anyone reading it. 📌𝗞𝗲𝘆 𝗧𝗮𝗸𝗲𝗮𝘄𝗮𝘆𝘀: • Look at mylist[-3:] in the image. This grabs the last 3 items, the "N!!", instantly. No math required! • What if you only need the very last item? Don't bother with len(list) -1. 👉🏻Just use mylist[-1]. It can be used to access the end of your data instantly. It’s a great reminder that the most efficient solution is often the most readable one✅ What was the first Python shortcut that made you realize you’d been doing way too much work in other languages? #Python #30DaysOfCode #Day10 #PythonTips #LearningInPublic
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