Day 48 : Python While Loops & Control Statements Today I understood while loop and its usage. Hands-on : - Today I explored while loops in Python, which are used to execute a block of code repeatedly as long as a condition remains true. - I started with the basic syntax of a while loop, understanding how it differs from a for loop by relying on conditions instead of sequences. - I then learned how to use the break statement, which allows exiting the loop immediately when a certain condition is met. - Next, I explored the continue statement, which skips the current iteration and moves to the next loop cycle without stopping the loop entirely. - Additionally, I learned about the else statement in a while loop, which executes only when the loop completes normally (i.e., not terminated by a break statement). Result : - Successfully understood how to use while loops along with break, continue, and else statements to control loop execution effectively. Key Takeaways : - While loops run as long as a condition is true. - Break is used to exit the loop early. - Continue skips the current iteration and moves to the next. - Else block executes when the loop finishes without interruption. - Proper loop control helps avoid infinite loops and improves logic building. #Python #Programming #DataAnalytics #LearningJourney #WhileLoop #CodingBasics #DataScience #BeginnerPython #AnalyticsSkills
Pratik Kinare’s Post
More Relevant Posts
-
Started exploring Python fundamentals and recently learned about variables and data types. A few quick takeaways: → Python is dynamically typed — no need to declare types explicitly → Variables are just references to objects in memory → Core data types are simple yet powerful: • int (numbers) • float (decimals) • str (text) • bool (True/False) • list, tuple, dict (collections) What stood out is how readable and beginner-friendly Python feels compared to other languages. Small concepts, but they form the foundation for everything ahead. On to the next step 🚀 #Python #Learning #Developers #Programming #TechJourney
To view or add a comment, sign in
-
🚀 Today I learned: Instance Variables vs Class Variables in Python While diving deeper into Python OOP, I explored an important concept — the difference between instance variables and class variables. Here’s a simple breakdown 👇 🔹 Instance Variables - Defined inside the "__init__" method - Unique for each object - Stored separately for every instance 🔹 Class Variables - Defined inside the class but outside methods - Shared by all objects of the class - Same value across all instances (unless changed) 💡 Key Difference: - Instance variable → Object-specific - Class variable → Shared across all objects Understanding this helps in writing efficient and structured code, especially when working on larger projects. #Python #OOP #Programming #Coding #LearningJourney #100DaysOfCode
To view or add a comment, sign in
-
-
At this point, Python is starting to feel less like a language… and more like a toolkit. Today’s Python MahaRevision 🧠 Chapter 13: Advanced Python (Part 2) This chapter introduced some really powerful and practical concepts: → Virtual environments → pip freeze (managing dependencies) → Lambda functions → bin() method → format() function → map, filter, reduce It’s interesting how these tools make code shorter, cleaner, and more efficient—once you understand how to use them properly. Practice set done: Worked on applying lambda functions, transforming data using map/filter, experimenting with reduce, and managing environments and dependencies. Some concepts felt a bit abstract at first (especially map/filter/reduce)… but with practice, they started making more sense. Biggest takeaway: Better tools don’t just make coding easier—they change how you think about solving problems. Still exploring, still improving. #Python #LearningInPublic #CodingJourney #Programming #AdvancedPython
To view or add a comment, sign in
-
🔁 For Loop vs While Loop in Python — Simple Difference Understanding loops is one of the first steps in mastering Python. Here's a quick comparison: ✅ For Loop Used when the number of iterations is known. Example: Iterating through a list, string, or range. for i in range(5): print(i) ✅ While Loop Used when the number of iterations is unknown and depends on a condition. i = 0 while i < 5: print(i) i += 1 📌 Key Difference for loop → iterate over sequence while loop → run until condition becomes False 💡 Tip: Use for loops for cleaner and readable code when working with collections. Use while loops when waiting for a condition (like user input). #Python #Coding #Programming #PythonBasics #LearnPython
To view or add a comment, sign in
-
𝗗𝗮𝘆 𝟵/𝟯𝟬 Instead of forcing my old coding habits into Python, I’m leaning into how the language handles data natively. Why write four lines of code when you can write one? 1. 𝗧𝗵𝗲 𝗦𝘁𝗮𝗻𝗱𝗮𝗿𝗱 𝗪𝗮𝘆 (Looping & Appending): nums = [1, 2, 3, 4] squared = [] for n in nums: squared.append(n * n) 2. 𝗧𝗵𝗲 𝗠𝗼𝗱𝗲𝗿𝗻 Approach 🚀: squared = [n * n for n in nums] 👉🏻It’s cleaner, faster, and much more intuitive. These are the small details that make the Python journey so satisfying🤌🏻 At what point do you find List Comprehensions become too complex? Do you stick to them for simple one-liners, or use them for nested logic too? #Python #30daysofcode #CodingJourney #Day9 #SoftwareDevelopment
To view or add a comment, sign in
-
-
#python #EP 1 Mastering Python Variables & Scope I’ve put together a beginner-friendly tutorial that covers everything we and I need to know about variables in Python — from naming rules and assignments to dynamic typing, object references, and the #LEGB scope resolution. 🔑 Key highlights in the tutorial: ✅ Rules for naming variables (valid vs invalid examples) 🎯 Assigning values & dynamic typing 📦 Multiple assignments in one line 🧩 Object references & how Python handles memory 🔍 Type checking & casting 🗑️ Deleting variables safely ⚡ Practical examples (swapping, counting characters) 🔑 Scope explained with the #LEGB rule (Local, Enclosing, Global, Built-in) 👉 Check out the full tutorial here: Python Variables & Scope – GitHub Repo git repo https://lnkd.in/g5vHi52w
To view or add a comment, sign in
-
-
⏰ Day 56 of My Python Journey – Building an Alarm Clock Today I combined my knowledge of date & time manipulation with automation and text-to-speech to create a simple alarm program in Python. 🔹 What I built: An alarm that checks the current time continuously using the datetime module. When the set alarm time matches, it triggers a voice alert using the pyttsx3 library. Added a loop to repeat the spoken message multiple times for emphasis. 🔹 Key Learnings: How to integrate multiple modules (datetime, time, pyttsx3) to solve a real-world problem. The importance of continuous loops and condition checks in automation tasks. How text-to-speech can make Python programs more interactive and user-friendly. ✨ Reflection: Crossing Day 56 feels exciting because I’m now building programs that connect directly to everyday life. From simple algorithms to now creating an alarm clock, Python is proving to be a versatile tool for both problem-solving and practical applications. #Python #Day56 #LearningJourney #Automation #TextToSpeech #CodingConsistency #ProblemSolving
To view or add a comment, sign in
-
Day 2/30 One extra space can silently change your program In Python, indentation isn’t just about readability. It defines what actually runs. Take this example: In one version: both lines are inside the “if” block → they run only if the condition is true. In another version: only the first line is inside the block, while the second line is outside → so it runs every time, regardless of the condition. Same code. Same lines. Different behavior. And the only difference is indentation. Coming from C++, this feels unusual. There, structure is defined using {} spacing doesn’t affect execution. But in Python, the structure is spacing. Which means a small shift in alignment can completely change your program’s logic. It forces you to be more intentional while writing code. Subtle, but once you notice it, you can’t ignore it. #Python #cpp #LearningInPublic #30DaysOfCode
To view or add a comment, sign in
-
-
Back in January, I started my Python journey with a simple goal: show up every day and learn something new. For the next few weeks, I shared topic-wise Python code and explanations on GitHub — covering everything from basics to core concepts like OOP, file handling, and more. I actually completed this journey about a month ago, but took some time to reflect on what I truly gained from it. Here’s what it taught me: • Consistency matters more than intensity • Writing code daily builds real confidence • Strong fundamentals make everything easier later It wasn’t always easy to stay consistent, but looking back, it was completely worth it. If you're just starting out, don’t overthink it — just begin and keep going. 🔗 GitHub: https://lnkd.in/g99jWh5p #Python #LearningInPublic #Consistency #CodingJourney
To view or add a comment, sign in
-
🚀 Just completed a small but useful Python project! I built a simple script that helps clean and organize cluttered files automatically. You know how messy folders get with random downloads, images, and documents? This project sorts them into proper folders in seconds. While working on this, I didn’t just learn Python — I understood how automation can save time in real life. Small projects like this build strong fundamentals and confidence. 📌 What I learned: -Working with file handling in Python -Using automation to solve daily problems -Writing cleaner and more structured code -This is just the beginning. Next step: building more advanced projects. Would love your feedback and suggestions! code and git hub repo:-https://lnkd.in/dhvuVQAA #Python #BeginnerProjects #Automation #CodingJourney #LearningByDoing
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