Day 10/60 Continuing Chapter 2: Flow Control Continuing Topic l - Making Decisions 2. Code blocks if statements don't decide on skipping or running the entire code. They only make decisions about a code block. We use an indentation of two spaces to highlight code blocks, like indenting this display statement. Indentation refers to the space between the code and the code editor's margin. A code block can be more than a one-liner. All lines with the same indentation belong to the same code block. We can see it here when we use print() to add one more line at the beginning. 🧩Code if True: print ("Look at me!") print("I'm a code block") 🖥️Output Look at me! I'm a code block If the indentation is incorrect, the computer can't understand your code. This leads to an IndentationError showing up in the console. Instead of using the boolean True , we can save it in a variable like greet and use it as the condition. 🧩Code greet = True if greet: print("Hello!") 🖥️Output Hello! Using a variable like greet set to False allows us to skip code like the display statement. 🧩Code greet = False if greet: print("Hello!") 🖥️Output is empty 🧠Challenge of the day What is the output of this code? 🧩Code if True: print ("Look at me!") print("I'm a code block") #python #ai #programming #bigtech
Python if Statements and Indentation
More Relevant Posts
-
💡 Data analysis workflows have become increasingly complex. In practice, they often require combining multiple tools: notebooks, scripts, AutoML frameworks, databases, and now AI assistants. We think this fragmentation slows things down. 𝐌𝐋𝐉𝐀𝐑 𝐒𝐭𝐮𝐝𝐢𝐨 𝐢𝐬 𝐨𝐮𝐫 𝐚𝐩𝐩𝐫𝐨𝐚𝐜𝐡 𝐭𝐨 𝐬𝐢𝐦𝐩𝐥𝐢𝐟𝐲𝐢𝐧𝐠 𝐭𝐡𝐢𝐬. 𝐀 𝐝𝐞𝐬𝐤𝐭𝐨𝐩 𝐞𝐧𝐯𝐢𝐫𝐨𝐧𝐦𝐞𝐧𝐭 𝐭𝐡𝐚𝐭 𝐛𝐫𝐢𝐧𝐠𝐬 𝐭𝐨𝐠𝐞𝐭𝐡𝐞𝐫: 🚀 Python notebooks 🚀 AutoML 🚀 AI-assisted data analysis 🚀 database connections — in a single, consistent workflow. The goal is not to replace Python 🐍 . It’s to reduce the overhead around using it. We’ve recorded a short introduction showing how these pieces fit together in practice. Less time on setup. More time on insights. Try MLJAR Studio today: 👉 https://mljar.com
To view or add a comment, sign in
-
Hello dudes and dudettes!! 🚀 Day 13/150 — Solved LeetCode 238: Product of Array Except Self Today’s problem was a perfect mix of simplicity and smart thinking 🤯 At first glance, it feels straightforward: 👉 For each element, multiply all the other elements But the catch? ⚡ You can’t use division ⚡ And you need to do it in O(n) time That’s where things get interesting. 🧠 Initial Thought My first instinct was: “Okay, just loop through the array and multiply everything except the current element.” But that leads to O(n²) time complexity ❌ Too slow for large inputs. 💡 The Breakthrough Moment Instead of recalculating everything again and again, I realized: 👉 Why not reuse previous computations? This leads to a powerful idea: Compute products from the left side Compute products from the right side Combine both 🔥 The Core Idea For every index: 👉 Answer = (product of elements on the left) × (product of elements on the right) No division. No repeated work. Just smart reuse. 📊 Example Input: [1, 2, 3, 4] We mentally break it like this: Left products → builds progressively from the start Right products → builds from the end Then combine both to get: 🎯 Output: [24, 12, 8, 6] 😎 What Made This Problem Interesting? It looks simple, but forces you to think efficiently Teaches how to avoid redundant computation Shows how powerful prefix & suffix patterns are 💡 What I Learned Don’t recompute — reuse Think in terms of patterns, not brute force Sometimes the best solution comes from splitting the problem into two passes 🎯 Key Takeaway “Efficiency isn’t about doing more work faster… it’s about doing less work smarter.” 🔥 Another step forward in the journey — learning to think, not just code. #LeetCode #Algorithms #DataStructures #ProblemSolving #CodingJourney #100DaysOfCode #Python #LearningInPublic
To view or add a comment, sign in
-
-
I built a tool that lets you ask questions about your codebase in plain English. 🧠 Like literally just type — "where is the FAISS vector store initialized?" — and it finds the exact file, function, and code for you. No more ctrl+F. No more digging through 20 files manually. It's called CodeMind. Getting started is super simple too — just paste your GitHub repo link and it'll clone it automatically, or upload a ZIP file if you prefer. That's it, you're ready to start asking questions. Here's how it works under the hood: → Loads your entire codebase → Breaks it into chunks and converts them into embeddings → Stores everything in a FAISS vector store → When you ask something, it pulls the most relevant code and sends it to Groq LLM for a proper answer Built with Python · LangChain · FAISS · Groq · Streamlit 🔗 Try it: https://lnkd.in/gYV8UfC8 🐙 GitHub: https://lnkd.in/gk3F5kZf Still a lot to improve but happy with how v1 turned out. Would love honest feedback from anyone into AI or dev tooling! 🙌 #RAG #LangChain #GenerativeAI #Python #OpenSource #BuildInPublic #AIEngineering
To view or add a comment, sign in
-
-
Software isn't just math; it's business logic. Day 9/90 of my AI Product Engineer sprint: Python Conditionals (If/Else). This isn't just basic syntax. It is the exact mechanism that routes users in an application: If user is premium -> Route to Gemini Pro. Else -> Route to Flash. I built a raw terminal script today forcing user inputs through a basic decision tree. It’s unpolished, but the underlying logic is exactly how companies route data automatically. You cannot architect complex AI pipelines if you don't control the basic flow of information.
To view or add a comment, sign in
-
-
Hello dudes and dudettes!! 🚀 Day 21/150 — Solved LeetCode 151: Reverse Words in a String Today’s problem was a great reminder that even something as simple as a sentence can hide a few tricky details 😄 At first glance, reversing words sounds easy… But once spaces start behaving weirdly, things get interesting. 🧠 What’s the Problem About? You’re given a string that contains words separated by spaces. Your task is to: 👉 Reverse the order of words 👉 Not the characters inside them 💡 Example Input: "the sky is blue" Output: 👉 "blue is sky the" 🔥 The Twist It’s not just about reversing words… The string might contain: Extra spaces at the beginning Extra spaces at the end Multiple spaces between words Example: " hello world " Expected Output: 👉 "world hello" So we also need to clean up the spaces while solving it. 🧠 The Thought Process Instead of overcomplicating things, I broke it down: Extract the words (ignore spaces) Reverse their order Join them back with a single space That’s it. Simple steps → clean solution. ⚙️ Why This Approach Works Splitting automatically removes extra spaces Reversing handles the order Joining ensures proper formatting No unnecessary checks. No messy conditions. 😎 Why This Problem Is Interesting It looks easy but tests your handling of edge cases Shows how built-in operations can simplify problems Reinforces the idea that clarity beats complexity 💡 What I Learned Clean input → clean output Breaking a problem into steps makes it easier Sometimes the best solution is the simplest one 🎯 Key Takeaway “Don’t fight the problem — break it down and let simple steps solve it.” 🔥 Another step forward in the journey — writing cleaner, smarter solutions. #LeetCode #Algorithms #Strings #ProblemSolving #CodingJourney #100DaysOfCode #Python #LearningInPublic
To view or add a comment, sign in
-
-
If I can’t run my code from last month, did I actually build anything? I spent way too much time this morning fighting with my own laptop. I tried to open a project I was working on a few weeks ago, and it just… broke. I had updated a library for something else, and it completely trashed my previous work. It’s the kind of mistake that makes you want to close your laptop and walk away. I’ve realized that building these systems is 10% math and 90% just staying organized. If you can't reproduce your work, it doesn't matter how smart your approach is. To stop the headache, I’ve moved to two simple rules for this series: 1. Every project lives in its own "box" I stopped installing things randomly. Now, every project has its own isolated environment. If I can't hand my work to someone else and have it run on their screen in 60 seconds, it's not finished. 2. Everything is just a map This was my big "Aha!" moment with the tech side. To a computer, a sentence or a customer profile is just a "dot" on a massive, invisible map. We call these 𝗩𝗲𝗰𝘁𝗼𝗿𝘀. Think of it like this: If two customers are "standing" near each other on that map, they probably like the same stuff. Measuring that distance (the Dot Product) is how Netflix knows what you want to watch next. It’s not magic. It’s just geometry. The 'Sanity' Folder Structure: I’m sticking to this simple skeleton for everything I build in this series: 𝗱𝗮𝘁𝗮/ -> The files. 𝗻𝗼𝘁𝗲𝗯𝗼𝗼𝗸𝘀/ ->The messy 'what if?' testing. 𝘀𝗿𝗰/ -> The clean, final code. 𝗿𝗲𝗾𝘂𝗶𝗿𝗲𝗺𝗲𝗻𝘁𝘀.𝘁𝘅𝘁 -> The list of 'ingredients.' (make sure to pin your versions) It’s a small change, but it means I spend my time building instead of debugging my own folders. What’s one habit that saved your sanity when you first started building stuff? #MachineLearning #Python #DataScience #BuildInPublic
To view or add a comment, sign in
-
-
🚀 From Confusion → Clarity: My Approach to “Sort the People” (LeetCode) Today I solved the Sort the People problem, and instead of jumping straight into sorting tricks, I focused on building clarity step by step 👇 🔍 My Thought Process: First, I paired each name with its corresponding height using a list (like a mini mapping). Then, I sorted this list based on height. Since the problem required descending order, I simply reversed the sorted list. Finally, I extracted only the names in the correct order. 💡 Key Learning: Sometimes, the simplest approach is the best one. Instead of overcomplicating with advanced data structures, breaking the problem into smaller transformations made it super manageable. 🧠 What this improved for me: Understanding how to use lambda for sorting Confidence in handling paired data (name + value problems) Thinking in steps rather than jumping to optimization ⚡ Code Strategy in One Line: Pair → Sort → Reverse → Extract Consistency > Speed. One problem at a time. 💪 📈 If you're also grinding DSA, keep going — progress compounds! #DSA #LeetCode #CodingJourney #Python #ProblemSolving #Consistency #TechGrowth #100DaysOfCode #WomenInTech #FutureEngineer
To view or add a comment, sign in
-
-
✅ Day 97 of 100 Days LeetCode Challenge Problem: 🔹 #1281 – Subtract the Product and Sum of Digits of an Integer 🔗 https://lnkd.in/gxTAZc6U Learning Journey: 🔹 Today’s problem involved extracting digits of a number and performing two operations simultaneously. 🔹 I initialized two variables: one for product (pr) and one for sum (sm). 🔹 Using a while loop, I extracted each digit using n % 10. 🔹 Updated the product by multiplying the digit and updated the sum by adding it. 🔹 Reduced the number using integer division (n //= 10) after each step. 🔹 Finally returned the difference between product and sum. Concepts Used: 🔹 Digit Extraction 🔹 While Loop 🔹 Arithmetic Operations 🔹 Number Manipulation Key Insight: 🔹 Both product and sum can be computed in a single traversal of digits. 🔹 Efficient use of modulus and division avoids converting the number to a string. Complexity: 🔹 Time: O(d) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
Built my first skill -- Large Codebase Survival Guide AI coding agents (Claude Code, Cursor, Windsurf, etc.) are incredibly powerful — until they aren't. When working with large files or complex multi-step tasks, the agent's context window fills up and the session dies permanently (HTTP 503). No recovery. No /clear. All unsaved progress — gone. This guide was born from months of painful experience migrating a 15,000+ line Python application from SimpleGUI to WebView using Claude Code. Countless sessions were lost to 503 errors before a reliable methodology emerged. https://lnkd.in/gdn8rxjd 6 Principles:
To view or add a comment, sign in
-
-
Hello dudes and dudettes!! 🚀 Day 19/150 — Solved LeetCode 58: Length of Last Word Today’s problem looked super simple at first… but taught me a great lesson about handling edge cases carefully 😄 🧠 What’s the Problem About? You’re given a string that contains words separated by spaces. Your task is to find the length of the last word. Sounds easy, right? Well… not always 👇 💡 The Catch The string might contain: Extra spaces at the beginning Extra spaces at the end Multiple spaces between words So it’s not just about “finding the last word” — it’s about finding the last valid word. 🔥 Example Input: " hello world " At first glance, it looks messy 😵 But the actual last word is: 👉 "world" 👉 Length = 5 🧠 The Thought Process Instead of trying to split everything immediately, I started thinking: Why not scan from the end? Because: The last word is always near the end We can skip spaces quickly Then just count characters until we hit a space ⚙️ Approach That Worked Ignore trailing spaces Start from the end of the string Count characters until a space appears That count is your answer Simple, efficient, and clean. 😎 Why This Problem Is Interesting It’s not about complexity — it’s about precision It shows how small edge cases can break simple logic It encourages thinking in reverse (which is surprisingly powerful) 💡 What I Learned Always consider edge cases like extra spaces Sometimes scanning backward is smarter than forward Even easy problems can sharpen your attention to detail 🎯 Key Takeaway “Simple problems aren’t always trivial — they test how carefully you think.” 🔥 Another step forward — improving not just coding skills, but problem-solving mindset. #LeetCode #Algorithms #ProblemSolving #CodingJourney #100DaysOfCode #Python #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