🚀 Day 3 of #14DaysOfPython 🐍 Today’s focus: Loops (Iteration Mastery) — where automation really begins. 💡 Easy way to understand loops: 🔹 Why loops? 👉 When you need to repeat a task multiple times instead of writing code again and again 💡 Core Concepts (Logic First): 🔹 for loop vs while loop for → when you know how many times to run while → when condition decides 🔹 range() variations range(n) → 0 to n-1 range(start, end) range(start, end, step) 🔹 Loop control break → stop loop immediately continue → skip current step pass → do nothing (placeholder) 🔹 Infinite loop ⚠️ 👉 Happens when condition never becomes false 🔹 Iteration patterns 👉 Numbers, strings, lists — everything can be looped 🧠 Problems I practiced: Sum of digits Reverse a number Factorial Count occurrences ✨ Key takeaway: Loops are not about syntax — they are about thinking in repetition and patterns. Day 3 done ✅ Moving to Day 4 💪 #Python #HackerRank #CodingJourney #LearningInPublic #ProblemSolving #DeveloperJourney #100DaysOfCode#codegnan
Python Loops for Iteration Mastery
More Relevant Posts
-
🚀 Day 50 of My Coding Journey Today, I explored powerful NumPy operations — sum() and prod() — and learned how combining them can solve interesting problems efficiently. 🔍 What I learned: sum(axis=0) → adds elements column-wise prod() → multiplies elements together By combining both, we can transform and reduce arrays in a single flow 💡 Problem Insight: Given a 2D array, 👉 First, compute the column-wise sum 👉 Then, find the product of that result 📌 Example: Input: 2 2 1 2 3 4 Step 1: Sum along axis 0 → [4, 6] Step 2: Product → 4 × 6 = 24 ✨ Key Takeaway: Understanding how axes work in NumPy makes complex operations simple and efficient. 💻 Code Snippet: import numpy as np n, m = map(int, input().split()) arr = [list(map(int, input().split())) for _ in range(n)] my_array = np.array(arr) result = np.prod(np.sum(my_array, axis=0)) print(result) 🔥 Day 50 done! Staying consistent and learning something new every day. #Day50 #Python #NumPy #CodingJourney #LearningEveryday
To view or add a comment, sign in
-
-
🚀 Mastering the art of loops! 🔄 Discover how loops help your code execute repetitive tasks efficiently. Essentially, loops are like a magical chant that tells your program to keep doing something until a certain condition is met. For developers, mastering loops is crucial for automating tasks and iterating over data structures with ease. Here's the breakdown: 1️⃣ Initialize a counter variable 2️⃣ Set the condition for the loop 3️⃣ Define the action to perform in each iteration Sample code using a "for" loop in Python: ``` for i in range(5): print("Hello, World!") ``` 🌟 Pro Tip: Use loops to reduce redundancy in your code and boost efficiency. 💡 ⚠️ Common Mistake: Forgetting to update the counter variable in the loop, leading to an infinite loop! 🔄 🌟 What's your favorite use case for loops in your projects? Let's discuss! 💬 #Coding101 #LearnToCode #TechTips #CodeNewbie #PythonProgramming #DeveloperCommunity #LoopLogic #CodeEfficiency #ProDevSkills 🌐 View my full portfolio and more dev resources at tharindunipun.lk
To view or add a comment, sign in
-
-
My new ebook just dropped. 👇 I spent weeks documenting the exact Claude Code automations our team uses to save 20 hours every week. The result: "Automate Everything" — 10 copy-paste automations for dev teams who are tired of doing manually what AI can do in seconds. What's inside: → Auto-triage GitHub issues (saves ~3 hrs/wk) → PR code review bot (saves ~5 hrs/wk) → Unit test generator (saves ~4 hrs/wk) → + 7 more production-ready automations Every automation includes a workflow diagram + Python/Bash code you can drop into your repo today. No fluff. Instant download. 🔗 https://lnkd.in/dvCxkpDp #ClaudeCode #AIAutomation #DevTools #Productivity #SoftwareEngineering
To view or add a comment, sign in
-
The first version of my Task Manager CLI was a mess. One big file. Everything tangled together. It worked — barely. Then I refactored it into modular components. Debugging effort dropped by 40%. Not because I became smarter, but because I could finally isolate problems instead of hunting through 300 lines of spaghetti code. That refactor taught me something no tutorial spells out clearly: Clean code isn't about aesthetics. It's about reducing the cost of being wrong. When you write modular code: → Bugs are easier to find → Features are easier to add → Other people (or future you) can actually understand it I now think about modularity before I write a single function. It's the difference between a project that grows and one that collapses under its own weight. What's a coding habit you wish you'd developed earlier in your journey? #CleanCode #SoftwareEngineering #Python #BackendDevelopment #CodingBestPractices
To view or add a comment, sign in
-
🚀 Just solved the Power of Two problem on LeetCode — and here’s a quick look at my approach 👇 Instead of jumping straight into bit manipulation, I focused on a simple iterative logic: 🔹 Start from 2 🔹 Keep multiplying by 2 🔹 Check if we reach the given number 🔹 If yes → it’s a power of two ✅ 🔹 If we overshoot → it’s not ❌ 💡 This approach emphasizes clarity over cleverness — building intuition step-by-step before optimizing further. While there are more optimized solutions (like bit tricks), I believe: 👉 Strong fundamentals > premature optimization 📊 Result: ✔️ 100% runtime efficiency ✔️ Clean and readable logic Always aiming to improve not just what I solve, but how I think 💭 #LeetCode #DSA #ProblemSolving #Python #CodingJourney #100DaysOfCode #WomenInTech #FutureEngineer #TechGrowth #Consistency #LearnInPublic #CodingLife #SoftwareEngineering #DeveloperMindset
To view or add a comment, sign in
-
-
Building this trading bot taught me how powerful clean architecture, modular design, and API‑driven automation can be. My goal wasn’t to create a complex system — but a simple, reliable, and transparent bot that anyone can understand. This project helped me sharpen my Python fundamentals, improve my debugging discipline, and design a structure that scales. Excited to keep improving it with strategies, risk checks, and backtesting. - Drafted with the help from Copilot. #Python #TradingBot #AlgorithmicTrading #PythonProjects #Automation #APIDevelopment #CodingJourney #LearningInPublic GIT hub link for code: https://lnkd.in/d_cCwG-r
To view or add a comment, sign in
-
🔥 Day 8/100 of My LeetCode Challenge — 0 ms (100%) 🔥 Hook: Most people fail this “easy” problem because they ignore one tiny detail — can you spot it? 💭 Problem: Add 1 to a number represented as an array of digits. Sounds simple, right? But here’s the catch 👇 👉 What if the last digit is 9? 👉 What if ALL digits are 9? Example: [9,9,9] → [1,0,0,0] 💥 🧠 What I learned today: Always think about edge cases Simple problems can hide tricky logic Traversing backwards can simplify carry problems ⚡ My Approach: Start from the end If digit < 9 → add 1 and return If digit == 9 → make it 0 and continue If all become 0 → add 1 at front 💻 Result: ✅ Runtime: 0 ms (100%) ✅ Clean & optimized solution 📈 Consistency Check Day 8 complete. No excuses. No breaks. Small wins daily → Big results later 🚀 #LeetCode #Day8 #CodingJourney #Python #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Today's office discussion took an unexpected turn, diving deep into the nuances of loops. We began with a seemingly simple question: What’s the real difference between a for loop and a while loop? Initially, it seemed straightforward: - Use a for loop when you know how many times to iterate. - Use a while loop when you only know the condition, not the count. However, the conversation quickly evolved. We discovered that the difference goes beyond syntax; it’s about intent and control. Interestingly, despite their differences, Python allows us to make for and while loops behave similarly. For instance: - A for loop is driven by an iterator. - A while loop is driven by a condition check. You can even rewrite a for loop using a while loop by manually handling the iterator. Ultimately, it’s not about which loop is more powerful; it’s about how you approach the problem. Final insights: - For loop → cleaner and more readable when iteration is defined. - While loop → more flexible when termination is dynamic. - Under the hood, both are simply different methods of controlling flow. It's fascinating how a "beginner topic" can lead to a rich discussion about Python internals and abstraction layers. Sometimes, the simplest concepts reveal the deepest insights. #Python #Programming #SoftwareEngineering #LearningEveryday #CleanCode
To view or add a comment, sign in
-
🚀 Day 84 of #100DaysOfCode ✅ Solved: Rotate Image (LeetCode 48) Today’s problem was all about rotating an n × n matrix by 90° clockwise — in-place (without using extra space). 💡 Key Insight: Instead of creating a new matrix, we can break the problem into two smart steps: 1️⃣ Transpose the matrix (swap rows with columns) 2️⃣ Reverse each row This transforms the matrix exactly as required — clean and efficient! 🧠 Why this works: - Transpose flips the matrix across its diagonal - Reversing rows completes the 90° clockwise rotation ⚡ Complexity: - Time: O(n²) - Space: O(1) (in-place) 📌 Takeaway: Many matrix problems become easier when broken into transformations like transpose + reverse. Recognizing these patterns is a game-changer in coding interviews. #LeetCode #DataStructures #CodingJourney #Python #100DaysOfCode #ProblemSolving
To view or add a comment, sign in
-
-
🚀 Solved today’s LeetCode challenge: Longest Common Prefix 💻🔥 Problem: Given an array of strings, find the longest common starting substring among all strings. ✅ Example: ["flower", "flow", "flight"] → "fl" ["dog", "racecar", "car"] → "" 🧠 My Approach: Started with the first word as a prefix and compared it with the remaining strings one by one. Whenever a mismatch happened, I kept shrinking the prefix from the end until it matched. This helped me understand: 🔹 String slicing in Python 🔹 Prefix matching logic 🔹 Edge case handling 🔹 Writing optimized clean code 💡 Time Complexity: O(n * m) (n = number of strings, m = prefix length) Consistency > Motivation. One problem every day builds strong problem-solving skills 📈 Check Out : https://lnkd.in/dtumdVUQ #LeetCode #Python #DSA #CodingJourney #ProblemSolving #100DaysOfCode #SoftwareEngineer #Programming #Tech #Learning
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