🚀 Day 5 of Python Learning: Loops in Python Today I learned how to repeat tasks using loops — one of the most powerful concepts in programming. 🔹 What are Loops? Loops help us execute a block of code multiple times without writing it again and again. 🔸 For Loop Used when the number of iterations is known. Example: for i in range(1, 6): print(i) 🔸 While Loop Used when the number of iterations is not known. Example: i = 1 while i <= 5: print(i) i += 1 🔸 Loop Control Statements ✔ break → Stops the loop completely ✔ continue → Skips current iteration ✔ pass → Does nothing (placeholder) 💡 Key Learning: Use "for loop" for fixed iterations and "while loop" for condition-based execution. 🧪 Practice Task: Print numbers from 1 to 10 using a loop Find factorial of a number 🎯 Interview Question: What is the difference between for loop and while loop? Answer: "For loop is used when the number of iterations is known, while loop is used when the condition decides the execution." #Python #Learning #CodingJourney #Day5 #Programming #SDET Masai #dailylearning #masaiverse #SDET
Python Loops: For and While Loops Explained
More Relevant Posts
-
🚀 Day 6 of Python Learning: Functions in Python Today I learned how to organize and reuse code using functions — a key concept for writing clean and efficient programs. 🔹 What is a Function? A function is a block of code that performs a specific task and can be reused whenever needed. 🔸 Creating a Function Example: def greet(): print("Hello, welcome to Python!") greet() 🔸 Function with Parameters Example: def greet(name): print("Hello", name) greet("Rohit") 🔸 Function with Return Value Example: def add(a, b): return a + b result = add(5, 3) print(result) 💡 Key Learning: Functions help reduce code repetition and make programs more structured and readable. 🧪 Practice Task: Create a function to check even or odd Create a function to add two numbers Create a function to find the square of a number 🎯 Interview Question: What is the difference between return and print in Python? Answer: "print displays output on the screen, while return sends the value back to the function caller." #Python #Learning #CodingJourney #Day6 #Programming #SDET Masai #dailylearning #masaiverse #SDET
To view or add a comment, sign in
-
-
🎯 Tech Learning Journey - Day 06: Python List Comprehensions - Write Less, Do More! List comprehensions are a shortcut for creating lists in Python. Instead of writing multiple lines with loops, you can build a new list in just one clean line that reads like English. # Traditional way \(takes 3 lines\) squares = \[\] for num in range\(5\): squares.append\(num \*\* 2\) # List comprehension \(1 line!\) squares = \[num \*\* 2 for num in range\(5\)\] Where I use this: Transforming data, filtering lists, and making my code shorter and more readable. #Python #Coding #Programming #ListComprehensions
To view or add a comment, sign in
-
-
📚 Continuing my Python learning journey Today I explored more advanced list operations in Python, focusing on how to efficiently modify and work with lists. 🔑 Key concepts I learned and practiced: • Adding items – using append() and extend() • Removing items – using remove(), pop(), del, and clear() • Looping through lists – iterating over elements efficiently • List comprehension – writing concise and readable list transformations • Sorting lists – organizing data using sort() • Copying lists – creating copies without affecting the original list • Joining lists – combining multiple lists into one It’s interesting to see how these operations make lists extremely flexible and powerful for handling data. Step by step, I’m strengthening my Python fundamentals and problem-solving skills. 🚀 #Python #Programming #LearningJourney #ComputerScience #Coding
To view or add a comment, sign in
-
Python Learning Journey – Day 7 🚀 Today’s focus was on working with lists and improving problem-solving using Python. I practised different list operations and real-world scenarios to better understand how data can be handled efficiently. Here’s what I worked on: • Reversing a list • Finding common elements between two lists • Extracting unique elements • Removing duplicates while preserving order • List concatenation and repetition • Removing elements based on index conditions • Inserting elements into a list • List comprehensions (squares, even numbers, word lengths) This session helped me get more comfortable with list manipulation and writing cleaner, more efficient Python code using comprehensions. Step by step, improving logic and coding confidence. Big thanks to VASU KUMAR PALANI and PythonLife for the continuous guidance and support. #Python #CodingJourney #LearnInPublic #PythonLists #Programming #100DaysOfCode #Consistency #TechSkills
To view or add a comment, sign in
-
-
📘 Python Learning – Day 11 Highlights 🐍 Today’s class focused on writing more robust and real-world Python programs 👇 🔹 Namespaces: Learned how Python organizes variables using Local, Global, and Built-in scopes to avoid conflicts 🔹 Exception Handling: Used try, except, else, and finally to handle errors smoothly and prevent program crashes 🔹 File Handling: ✔ Read files (r) ✔ Write files (w) ✔ Append data (a) ✔ Safe handling using with open() 🔹 Practice & Mini Project: ✔ Word count program ✔ File-based number processing ✔ Student record system with average calculation 💡 Key Learning: Handling errors and working with files makes programs more practical and reliable Step by step, moving towards real-world Python development 🚀 #Python #Programming #Coding #LearningJourney #Beginner #TechSkills creat a attractive thumbnail of this lessons
To view or add a comment, sign in
-
-
🚀 Day 7 of Python Learning: Lists in Python Today I learned about Lists — one of the most useful data structures in Python for storing multiple values in a single variable. 🔹 What is a List? A list is a collection of items stored in a single variable. It can store different data types like numbers, strings, etc. 🔸 Creating a List my_list = [1, 2, 3, 4, 5] 🔸 Accessing Elements print(my_list[0]) # First element print(my_list[-1]) # Last element 🔸 Updating List my_list[1] = 10 🔸 Adding Elements my_list.append(6) 🔸 Removing Elements my_list.remove(3) 💡 Key Learning: Lists are mutable, which means we can change their values after creation. 🧪 Practice Task: ✔ Create a list of 5 numbers ✔ Add a new number ✔ Remove one number ✔ Print all elements using a loop 🎯 Interview Question: What is the difference between list and tuple in Python? Answer: "List is mutable (can be changed), while tuple is immutable (cannot be changed)." 📌 Day 7 done — building consistency step by step! #Python #Learning #CodingJourney #Day7 #Programming #SDET #100DaysOfCode Masai #dailylearning, #masaiverse
To view or add a comment, sign in
-
-
📚 Continuing my Python learning journey Today I completed learning three important Python data structures: tuples, sets, and dictionaries. 🔑 Key concepts I explored: • Tuples – ordered, immutable collections used for fixed data • Sets – unordered collections with unique elements, useful for removing duplicates and fast lookups • Dictionaries – key-value pairs for storing and accessing structured data efficiently Understanding the differences between these data structures helped me see when and why to use each one in real-world scenarios. It’s interesting how each structure is designed for a specific purpose, making Python both powerful and flexible. Step by step, I’m building a stronger foundation in Python programming and problem-solving. 🚀 #Python #Programming #LearningJourney #ComputerScience #Coding
To view or add a comment, sign in
-
📚 Continuing my Python learning journey Today I explored exception handling and file handling in Python, focusing on writing more reliable and practical programs. 🔑 Key concepts I learned and practiced: • Exception handling – using try, except, else, and finally to handle errors gracefully • Types of exceptions – understanding common runtime errors • Raising exceptions – using raise to trigger custom errors • File handling basics – opening, reading, writing, and closing files • File modes – working with r, w, a modes • Working with files safely – using with statement for better resource management Learning how to handle errors and work with files makes programs more robust, efficient, and real-world ready. Step by step, I’m strengthening my Python fundamentals and problem-solving skills. 🚀 #Python #Programming #LearningJourney #ComputerScience #Coding
To view or add a comment, sign in
-
🔁 Python Revision – Lists & List Comprehension Continuing my Python fundamentals revision 🐍 In this session, I focused on: ✔️ Lists (creation, indexing, slicing) ✔️ List methods (append, remove, sort, etc.) ✔️ Iterating through lists ✔️ List Comprehension Practiced working with lists to store and manipulate data efficiently, and explored list comprehension for writing cleaner and more concise code. Documented my practice in a Python Notebook and shared it as a PDF to track my progress. Learning how to handle data in Python step by step 📊 #Python #Revision #Lists #ListComprehension #Programming #DataAnalytics #LearningJourney
To view or add a comment, sign in
-
🚀 Day 18 of Python Learning: Abstraction in Python Today I learned about Abstraction in Python — an important Object-Oriented Programming (OOP) concept that focuses on hiding implementation details and showing only essential features. 🔹 What is Abstraction? Abstraction means hiding the internal complexity of a system and exposing only the necessary functionality to the user. 🔸 Why Use Abstraction? ✔ Reduces complexity ✔ Improves code readability ✔ Enhances security by hiding details 🔸 Example Using Abstract Class from abc import ABC, abstractmethod class Shape(ABC): @abstractmethod def area(self): pass class Circle(Shape): def area(self): return 3.14 * 5 * 5 class Rectangle(Shape): def area(self): return 4 * 6 c = Circle() r = Rectangle() print(c.area()) print(r.area()) 💡 Key Learning: Abstract classes define a structure, and child classes must implement the required methods. 🧪 Practice Task: ✔ Create an abstract class Vehicle ✔ Add abstract method start() ✔ Create Car and Bike classes ✔ Implement start() method in both 🎯 Interview Question: What is the difference between abstraction and encapsulation? Answer: Abstraction hides implementation details, while encapsulation hides data and controls access to it. 📌 Day 18 completed — mastering core OOP concepts step by step! #Python #Learning #CodingJourney #Day18 #Programming #SDET #100DaysOfCode Masai #masaiverse #dailylearning
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