🚀 𝗗𝗮𝘆 𝟯 𝗼𝗳 𝗠𝘆 𝗣𝘆𝘁𝗵𝗼𝗻 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴 𝗝𝗼𝘂𝗿𝗻𝗲𝘆 Today I focused on understanding some of the core building blocks of programming in Python. 𝗧𝗼𝗱𝗮𝘆’𝘀 𝗧𝗼𝗽𝗶𝗰𝘀: • While Loop – Learned how to execute code repeatedly while a condition remains true. • For Loop – Used to iterate through ranges, lists, and sequences efficiently. • Functions – Understood how to organize code into reusable blocks. • Recursion – Explored how a function can call itself to solve problems step-by-step. 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲𝗱 𝗣𝗿𝗼𝗯𝗹𝗲𝗺𝘀: ✔ Printed star patterns using loops ✔ Built number triangle patterns ✔ Used recursion to print list elements ✔ Practiced loop logic with different pattern problems Example of a recursion concept I practiced: 𝘥𝘦𝘧 𝘱𝘳𝘪𝘯𝘵_𝘭𝘪𝘴𝘵(𝘢𝘳𝘳, 𝘪𝘥𝘹=0): 𝘪𝘧 𝘪𝘥𝘹 == 𝘭𝘦𝘯(𝘢𝘳𝘳): 𝘳𝘦𝘵𝘶𝘳𝘯 𝘱𝘳𝘪𝘯𝘵(𝘢𝘳𝘳[𝘪𝘥𝘹]) 𝘱𝘳𝘪𝘯𝘵_𝘭𝘪𝘴𝘵(𝘢𝘳𝘳, 𝘪𝘥𝘹 + 1) This helped me understand how recursion works internally using the call stack. 💡 𝐊𝐞𝐲 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠 𝐓𝐨𝐝𝐚𝐲: Loops control repetition, functions organize logic, and recursion solves problems by breaking them into smaller parts. Every day I’m improving my problem-solving ability and programming mindset. On to 𝗗𝗮𝘆 𝟰 𝗼𝗳 𝗣𝘆𝘁𝗵𝗼𝗻 tomorrow. #Python #LearningInPublic #Programming #DeveloperJourney #100DaysOfCode
Python Day 3: Loops, Functions, Recursion and Practice
More Relevant Posts
-
🚀 Python Journey — Day 15 | Advanced List Logic with Functions Today I continued practicing functions by solving more advanced list-based logical problems. Problems I solved : • Find second largest number in a list • Find second smallest number in a list • Copy elements from one list to another • Print all prime numbers from a list • Replace all zero values with a given number • Check whether all elements in a list are same • Find frequency of all elements in a list • Flatten a nested list into a single list • Split a list into even and odd lists • Find pairs of elements with a given sum • Remove all odd numbers from a list • Remove all even numbers from a list • Multiply all list elements by a fixed number • Find difference between maximum and minimum values • Check whether a list is empty I implemented these problems using functions, loops, and conditional logic to strengthen my understanding of advanced list manipulation and structured problem solving. Thanks to Rudra Sravan kumar sir for the guidance and continuous support. Learning daily and getting more confident On to Day 16 #Python #PythonDeveloper #LogicBuilding #10000Coders #Coding #LearningJourney #ProblemSolving #CodeEveryDay #KeepLearning
To view or add a comment, sign in
-
If your code is getting longer… ................................................................. you’re probably doing something wrong. That hit me hard while doing today’s Python MahaRevision 👇 📘 Chapter 8: Functions & Recursion Instead of writing the same logic again and again, I learned how to simplify everything: → Functions: write once, reuse anytime → Parameters & return values → Breaking big problems into smaller pieces → Recursion: when a function calls itself Practice set done: Built functions for repeated tasks, passed inputs, returned outputs, and tried recursion problems (confusing at first, but interesting). Not gonna lie—recursion felt weird in the beginning. But it also showed me a different way of thinking. The real shift? It’s not about writing more code… it’s about writing smarter code. Slowly starting to see the bigger picture. #Python #LearningInPublic #CodingJourney #Programming #100DaysOfCode
To view or add a comment, sign in
-
Stop Googling the Basics. 🐍✨ Let’s be real: even after years of coding, we all occasionally forget the exact syntax for a list slice or a dictionary method. I’ve put together this Python Basic Cheatsheet designed to look as sharp as your IDE's dark mode. Whether you’re just starting your journey or you’re a pro who needs a quick visual refresher, this covers the essentials: Data Types & Functions (The bread and butter) List Operations (Indexing made easy) Control Flow (f-strings and loops) Advanced Concepts (Classes, Decorators, and Context Managers) Save this post for the next time you're stuck in a flow state and don't want to break it! #Python #Coding #Programming #SoftwareDevelopment #DataScience #WebDev #TechTips
To view or add a comment, sign in
-
-
They wanted to repeat 10 times. They used while, forgot to increment. Infinite loop. With for i in range(10) you get 0..9 automatically. No counter to forget. Same idea, fewer bugs. I wrote a beginner guide that covers for and range(): ✅ while vs for — condition vs "each element in a sequence" ✅ for over a string (for x in "Hello") ✅ range(stop), range(start, stop), range(start, stop, step) ✅ Negative step to count down (e.g. 10 down to 1) ✅ for i in range(10) to repeat N times; range(1, 11) for 1 to 10 ✅ Common patterns and summary ~5 min read. No fluff. https://lnkd.in/g6HY7erg #Python #Programming #Coding #Beginners #LearnToCode #ForLoop #Range #Practice #Tech #SoftwareDevelopment #CodingTips
To view or add a comment, sign in
-
🚀 30 𝐃𝐚𝐲𝐬 𝐨𝐟 𝐏𝐲𝐭𝐡𝐨𝐧 — 𝐃𝐚𝐲 #16 | 𝐋𝐢𝐬𝐭 𝐅𝐮𝐧𝐜𝐭𝐢𝐨𝐧𝐬 & 𝐌𝐞𝐭𝐡𝐨𝐝𝐬 Day 16 was focused on exploring list functions and methods that make working with lists more efficient and powerful. After understanding the basics of lists, I learned today that Python provides built-in methods to easily modify, manage, and analyze list data. 📌 𝐖𝐡𝐚𝐭 𝐈 𝐂𝐨𝐯𝐞𝐫𝐞𝐝: 🔹 Adding elements using 𝐚𝐩𝐩𝐞𝐧𝐝() and 𝐢𝐧𝐬𝐞𝐫𝐭() 🔹 Removing elements with 𝐫𝐞𝐦𝐨𝐯𝐞() and 𝐩𝐨𝐩() 🔹 Sorting lists using 𝐬𝐨𝐫𝐭() 🔹 Reversing lists with 𝐫𝐞𝐯𝐞𝐫𝐬𝐞() 🔹 Counting occurrences using 𝐜𝐨𝐮𝐧𝐭() 🔹 Finding element positions with 𝐢𝐧𝐝𝐞𝐱() Learning these methods made it clear how Python simplifies operations on data collections. 💡 𝐊𝐞𝐲 𝐓𝐚𝐤𝐞𝐚𝐰𝐚𝐲: Built-in list methods save time and make code cleaner by handling common operations efficiently. Day 16 complete ✅ Each new concept is making Python feel more powerful and intuitive. 💻✨ #Python #30DayChallenge #Day16 #PythonLists #ListMethods #CodingJourney #LearnToCode #Programming #TechGrowth #Consistency
To view or add a comment, sign in
-
-
After years of coding, I've come to accept the universal truth of debugging: It's always the data type. You spend 45 minutes convinced your logic is broken. You check the function over and over again. You rewrite it once or twice. You question your career choices. You think about buying a flight far far away where python is just a snake… Then you check the data type and go: ...oh. It's a string. It's been a string this whole time. Not whatever you were absolutely certain it was. The function was fine. The logic was fine. I've started treating it not as a mistake, but more as a lesson. It’s a reminder that assumptions are the enemy and every part of the code needs to be checked. #Programming #coding #TechHumor #DataEngineering #Python #DebuggingLife #CodeNewbie
To view or add a comment, sign in
-
Understanding Recursion Through Factorials Recursion is a powerful programming technique where a function calls itself to solve smaller instances of the same problem. In the example above, we compute the factorial of a number, defined as the product of all positive integers up to that number. It showcases the recursive nature of breaking down the problem into manageable parts. The base case, where recursion halts, is crucial. For factorial, we establish that the factorial of 0 or 1 is 1. This not only stops further recursive calls but prevents infinite loops, ensuring that our function eventually returns a value. Each call to the `factorial` function reduces `n` by 1, moving closer to that base case. What makes recursion valuable is its ability to simplify complex problems. Instead of using loops, recursive calls handle the iterations in a cleaner way. This is especially useful in algorithms like tree traversals or backtracking, where recursion often provides a more intuitive solution than traditional loops. However, understanding when and how to use recursion correctly is vital. Each recursive call consumes stack memory. If the recursion depth exceeds the limits, it can lead to a stack overflow. Knowing the base case helps us avoid such pitfalls and maintain efficiency in our code. Quick challenge: What will `factorial(6)` output? Why does it return that value? #WhatImReadingToday #Python #PythonProgramming #Recursion #Algorithms #SoftwareDevelopment
To view or add a comment, sign in
-
-
🚀 Day 14 of My Python Learning Journey Yesterday’s session was all about strengthening my understanding of loops and data type conversions — and honestly, it helped me connect multiple concepts together. 🔹 What I learned: How for loops work with range(start, end, step) Generating sequences like even numbers using step values Converting between data types: String → int, list, tuple Int → string, float List ↔ tuple, tuple → list List of tuples → dictionary Reversing a string using loops and slicing Checking for palindrome strings Writing logic to identify even and odd numbers 🔹 Key takeaway: Understanding loops deeply makes problem-solving much easier. Small tasks like reversing a string or checking palindrome really build strong logic 💡 📌 Practiced multiple mini problems to strengthen fundamentals and improve coding confidence. Consistency is starting to pay off — one step closer to becoming a better developer 🚀 #Python #LearningJourney #Coding #100DaysOfCode #Programming #DeveloperGrowth Codegnan BhanuTeja Garikapati
To view or add a comment, sign in
-
-
🚀 𝐃𝐚𝐲 9/60 – 60-𝐃𝐚𝐲 𝐏𝐲𝐭𝐡𝐨𝐧 𝐂𝐡𝐚𝐥𝐥𝐞𝐧𝐠𝐞 Today's topic is "𝐂𝐨𝐧𝐝𝐢𝐭𝐢𝐨𝐧𝐚𝐥 𝐞𝐱𝐞𝐜𝐮𝐭𝐢𝐨𝐧" Conditional execution in Python using 𝒊𝒇, 𝒆𝒍𝒊𝒇 and 𝒆𝒍𝒔𝒆 enables a program to choose between alternative code paths based on boolean expressions. An if statement executes its block 𝒘𝒉𝒆𝒏 𝒕𝒉𝒆 𝒄𝒐𝒏𝒅𝒊𝒕𝒊𝒐𝒏 𝒊𝒔 𝒕𝒓𝒖𝒆; elif provides additional conditions to test 𝒊𝒇 𝒕𝒉𝒆 𝒑𝒓𝒆𝒗𝒊𝒐𝒖𝒔 𝒐𝒏𝒆𝒔 𝒂𝒓𝒆 𝒇𝒂𝒍𝒔𝒆; and else supplies a fallback block when 𝒂𝒍𝒍 𝒑𝒓𝒊𝒐𝒓 𝒄𝒐𝒏𝒅𝒊𝒕𝒊𝒐𝒏𝒔 𝒇𝒂𝒊𝒍. This structure supports clear, readable decision logic and helps handle multiple potential scenarios efficiently. 𝐄𝐱𝐚𝐦𝐩𝐥𝐞: python 𝘵𝘦𝘮𝘱𝘦𝘳𝘢𝘵𝘶𝘳𝘦 = 72 𝘪𝘧 𝘵𝘦𝘮𝘱𝘦𝘳𝘢𝘵𝘶𝘳𝘦 > 85: 𝘱𝘳𝘪𝘯𝘵("𝘐𝘵'𝘴 𝘩𝘰𝘵 𝘰𝘶𝘵𝘴𝘪𝘥𝘦.") 𝘦𝘭𝘪𝘧 𝘵𝘦𝘮𝘱𝘦𝘳𝘢𝘵𝘶𝘳𝘦 < 60: 𝘱𝘳𝘪𝘯𝘵("𝘐𝘵'𝘴 𝘤𝘩𝘪𝘭𝘭𝘺 𝘰𝘶𝘵𝘴𝘪𝘥𝘦.") 𝘦𝘭𝘴𝘦: 𝘱𝘳𝘪𝘯𝘵("𝘛𝘩𝘦 𝘵𝘦𝘮𝘱𝘦𝘳𝘢𝘵𝘶𝘳𝘦 𝘪𝘴 𝘤𝘰𝘮𝘧𝘰𝘳𝘵𝘢𝘣𝘭𝘦.") Understanding these operators made me realize how programs make decisions and perform actions based on logic. They may look like simple symbols, but they are essential for writing meaningful code. Step by step, building stronger logic. #learning #python #consistency #challenge #60days #coding #programming
To view or add a comment, sign in
-
-
Utilizing the Math Module for Square Roots and Factorials Modules in Python are essential for code organization and reusability, and the `math` module serves as a built-in resource that provides a variety of mathematical functions. When you import a module, you bring a toolkit of pre-defined functions, constants, and classes into your workspace, simplifying complex tasks without needing to rewrite code. In the example above, we leverage the `math` module to perform two mathematical operations: calculating the square root and finding the factorial. The `math.sqrt()` function efficiently computes the square root of a number, while `math.factorial()` finds the factorial of a given integer. These built-in functions illustrate how you can significantly simplify coding tasks by utilizing existing libraries. Importing a module is straightforward with the `import` keyword, and functions within the module are accessed via dot notation. This allows for easy calls like `math.sqrt()` and `math.factorial()` after importing `math`. Understanding this concept encourages the use of Python's built-in capabilities, enhancing both maintainability and readability of your code. Additionally, you can create your own modules. This feature lets you encapsulate related functions and classes, making your code reusable across different projects. Writing modular code not only keeps your main script clean but also facilitates collaboration, allowing others to navigate your code structure more easily. Quick challenge: What would you need to change in the code if you wanted to find the natural logarithm instead? #WhatImReadingToday #Python #PythonProgramming #Modules #CodeReuse #Programming
To view or add a comment, sign in
-
More from this author
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
All the best 👍