Day 17 : of My Python Learning Journey Today I pushed the boundaries of Lambda Functions and List Comprehension to handle more complex logic in single lines ⚡ 🔹 What I learned and practiced: ✔️ Conditional Lambdas Writing Lambda functions that include if-else logic. Handling different return values based on input conditions without a full def block. ✔️ Nested List Comprehensions Using list comprehension within another list comprehension. 🔹 Hands-on Practice: ✔️ Created a lambda function to check if a number is positive, negative, or zero in one expression. ✔️ Used nested list comprehension to extract specific elements from a list of lists (matrices). Key takeaway: By combining List Comprehension with Lambda, we can transform and filter data structures simultaneously, keeping the code concise and highly efficient. Learning consistently and improving my coding skills step by step 💪 #Python #Lambda #codegnan #CodingJourney
Python Lambda Functions and List Comprehension Mastery
More Relevant Posts
-
🚀 Day 13 of Python Learning: Exception Handling in Python Today I learned how to handle errors in Python using exception handling. This helps programs run smoothly even when unexpected issues occur. 🔹 What is Exception Handling? Exception handling is used to catch errors and prevent the program from crashing. 🔸 Basic Example try: num = 10 / 0 except: print("Error occurred") 🔸 Handling Specific Error try: number = int("abc") except ValueError: print("Invalid input") 🔸 Using Finally Block try: print("Start") except: print("Error") finally: print("This always runs") 🔸 Using Else Block try: print(10 / 2) except: print("Error") else: print("No error found") 💡 Key Learning: Using try-except makes programs more reliable and user-friendly. 🧪 Practice Task: ✔ Handle divide by zero error ✔ Handle invalid number input ✔ Use finally block in one program ✔ Create a safe calculator using try-except 🎯 Interview Question: What is the purpose of finally block in Python? Answer: The finally block always executes whether an error occurs or not. It is commonly used for cleanup tasks like closing files or database connections. 📌 Day 13 completed — learning how professionals handle errors! #Python #Learning #CodingJourney #Day13 #Programming #SDET #100DaysOfCode Masai #masaiverse #dailylearning
To view or add a comment, sign in
-
Day 35 of python learning journey Today’s Python topic: Types of Patterns 👩💻🔥 Practiced how to build logic using patterns. As shown in the image, I covered 4 main types: 1. Star Patterns → Using `*` to create shapes like triangles and pyramids. Helps understand loops and spacing. 2. Number Patterns→ Arranging numbers in increasing or decreasing order. Builds strong logical thinking. 3. ABC Patterns → Printing alphabets A, B, C in order. Great for understanding sequences. 4. Pyramid Patterns → Centered shapes using spaces + symbols. Best way to learn alignment and indentation. Why patterns matter: They improve programming skills, help with loops, build logic, and are super useful in coding interviews. Bottom line from today: *Patterns = Practice + Logic + Creativity* Special thanks to the CEO G.R NARENDRA REDDY Sir for constant guidance and motivation. #Python #PatternProgramming #Loops
To view or add a comment, sign in
-
-
🚀 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
-
-
Understanding Python list methods is essential for writing clean and efficient code. From adding elements using append() to removing items with remove() and organizing data with sort(), these built-in functions make data handling simple and powerful. 💡 Key methods every Python learner should know: ✔ append() – Add elements to a list ✔ remove() – Remove specific items ✔ pop() – Remove elements by index ✔ insert() – Add elements at a specific position ✔ sort() – Arrange data efficiently Consistent practice of these methods can significantly improve your problem-solving skills and coding efficiency. #Python #Programming #Coding #DataStructures #Learning #AI #Developers #Tech
To view or add a comment, sign in
-
-
🚀 Day 11 of Python Learning: Loops and Patterns in Python Today I practiced loops in Python and learned how to create patterns using nested loops. This helps improve logic building and problem-solving skills. 🔹 What are Patterns? Patterns are shapes or number/star designs created using loops. They are great for understanding loop control and nested loops. 🔸 Using For Loop for i in range(5): print("*") 🔸 Star Pattern Example for i in range(1, 6): print("*" * i) Output: * ** 🔸 Number Pattern Example for i in range(1, 6): for j in range(1, i + 1): print(j, end=" ") print() 💡 Key Learning: Nested loops are useful when one loop runs inside another loop, especially for patterns and matrix-style problems. 🧪 Practice Task: ✔ Print reverse star pattern ✔ Print square pattern using stars ✔ Print number triangle pattern ✔ Try same patterns using while loop 🎯 Interview Question: What is a nested loop in Python? Answer: A nested loop is a loop inside another loop. It is used when repeated iterations are needed within each cycle of the outer loop. 📌 Day 11 completed — logic building step by step! #Python #Learning #CodingJourney #Day11 #Programming #SDET #100DaysOfCode Masai #dailyleaning #masaiverse
To view or add a comment, sign in
-
🚀 Python Learning Series – Day 4 Aaj maine Functions in Python ke baare me seekha 👇 Functions ka use code ko reusable aur organized banane ke liye hota hai. Ek baar function likho, aur use multiple baar use karo. 🔹 Function kya hota hai? Ek block of code jo specific task perform karta hai 🔹 Kaise banate hain? "def" keyword ka use karke function define kiya jata hai 🔹 Parameters & Return Value - Parameters: input jo function ko diya jata hai - Return: output jo function wapas deta hai 💡 Simple Example: def add(a, b): return a + b result = add(5, 3) print(result) 👉 Output: 8 📌 Real Life Example: Jaise ek machine jo input leti hai aur output deti hai ⚙️ ✨ Aaj ka learning: Functions help in writing clean, reusable, and efficient code. #Python #Learning #CodingJourney #Functions #Programming #Beginners
To view or add a comment, sign in
-
Day 20 of my Python learning journey Today I worked on a problem that completely changed how I look at arrays. At first, it looked like a normal question… But the solution came from a linked list concept. Problem: Find the Duplicate Number (O(1) Space) You are given an array of size n + 1 containing numbers from 1 to n. There is only one duplicate number, but it can appear multiple times. Find the duplicate without modifying the array and using constant space. Example: arr = [1, 3, 4, 2, 2] Output: 2 What I tried first: Using a set → works but uses extra space Sorting → modifies the array Both were not allowed. What I learned today: We can treat the array like a linked list. Each index → node Value → next pointer This creates a cycle, and the duplicate number is where the cycle starts. Optimized approach: Floyd’s Cycle Detection Slow pointer moves 1 step Fast pointer moves 2 steps Step 1: Find the meeting point inside the cycle Step 2: Find the starting point of the cycle (duplicate) Code: def findDuplicate(arr): # Step 1: Detect cycle (meeting point) slow = arr[0] fast = arr[0] while True: slow = arr[slow] fast = arr[arr[fast]] if slow == fast: break # Step 2: Find cycle start (duplicate) slow = arr[0] while slow != fast: slow = arr[slow] fast = arr[fast] return slow # Example arr = [1, 3, 4, 2, 2] print(findDuplicate(arr)) Problems I faced while solving this: I could not understand how an array can behave like a linked list The idea of cycle detection in arrays felt confusing I kept going back to sorting and hashing methods What I finally understood: This problem is not about arrays… It’s about recognizing hidden patterns. Time and Space Complexity: Time Complexity: O(n) Space Complexity: O(1) Question: Why do fast and slow pointers always meet inside a cycle? Today’s realization: Sometimes the solution is not in the data structure you see… but in the one you don’t see at first. #Python #DSA #Coding #Programming #LearningInPublic #100DaysOfCode #PythonProgramming
To view or add a comment, sign in
-
-
🚀 Day 27 of My Python Learning Journey 🚀 Today I explored one of the most powerful concepts in Python: Polymorphism. 📌 Topics I Learned: 🔹 Advantages of Polymorphism • Improves code reusability • Makes programs more flexible • Reduces complexity • Helps in writing cleaner and scalable code 🔹 Important Terminologies in Python Polymorphism • Method Overriding • Operator Overloading • Duck Typing • Magic Methods 🔹 Duck Typing Philosophy in Python “If it walks like a duck and talks like a duck, then it is a duck.” 🦆 Python does not care about the object type, it only cares whether the required method or behavior is present. 🔹 Operator Overloading Python allows us to redefine the behavior of operators for user-defined objects. Example: + operator can perform different tasks: • Addition for numbers • Concatenation for strings and lists 🔹 Method Overriding A child class can redefine the method of the parent class with its own implementation. 🔹 Magic Methods Used for Operator Overloading • add() → + • sub() → - • mul() → * • truediv() → / • lt() → < • gt() → > • eq() → == 🔹 Error Associated with + Operator Trying to add incompatible data types gives an error. Example: 5 + "Python" Output: TypeError: unsupported operand type(s) for +: 'int' and 'str' Learning polymorphism made me realize how Python gives flexibility to write smart and dynamic code. Excited to learn more every day! 💻✨ Thanks for your support G.R NARENDRA REDDY sir #Day27 #Python #Polymorphism #DuckTyping #OperatorOverloading #MethodOverriding #MagicMethods #PythonProgramming #CodingJourney #LearningPython #FutureDeveloper
To view or add a comment, sign in
-
-
🚀 Day 8 of Python Learning: Tuples and Sets in Python Today I learned about Tuples and Sets — two important data structures in Python used for storing collections of data efficiently. 🔹 What is a Tuple? A tuple is an ordered collection of items that cannot be changed after creation (immutable). 🔸 Creating a Tuple my_tuple = (1, 2, 3, 4, 5) 🔸 Accessing Elements print(my_tuple[0]) # First element print(my_tuple[-1]) # Last element 🔹 What is a Set? A set is an unordered collection of unique items. Duplicate values are automatically removed. 🔸 Creating a Set my_set = {1, 2, 3, 4, 4, 5} print(my_set) Output: {1, 2, 3, 4, 5} 🔸 Adding Elements my_set.add(6) 🔸 Removing Elements my_set.remove(3) 💡 Key Learning: Use tuples when data should not change, and sets when you need unique values only. 🧪 Practice Task: ✔ Create a tuple of 5 numbers ✔ Create a set with duplicate values ✔ Add and remove elements from a set ✔ Print all tuple values using a loop 🎯 Interview Question: What is the difference between list, tuple, and set in Python? Answer: List is ordered and mutable, tuple is ordered and immutable, while set is unordered and stores only unique values. 📌 Day 8 completed — learning one step at a time! #Python #Learning #CodingJourney #Day8 #Programming #SDET #100DaysOfCode Masai #masaiverse #dailylearning
To view or add a comment, sign in
-
Today i have just revised this topic in python 💡 __init__ Method in Python — The Foundation of OOP 🚀 Many beginners learn classes in Python… But understanding __init__ is where things start to make real sense. Let’s break it down simply 👇 🧱 What is __init__? 👉 It’s a special method (constructor) 👉 Runs automatically when an object is created 👉 Used to initialize object data (attributes) 🔍 Example: class Student: def __init__(self, name): self.name = name s1 = Student("Naveen") print(s1.name) 👉 Output: Naveen ⚙️ How it works ✔ When you create an object → Student("Naveen") ✔ __init__ runs automatically ✔ Value is assigned to the object (self.name) 🎯 Why is it important? ✔ Initializes data instantly ✔ Keeps code clean and structured ✔ Makes real-world modeling easier 🔥 Key Concepts ✔ self → refers to current object ✔ Can handle multiple attributes ✔ Supports default values ✔ Improves readability 💭 In simple words: 👉 __init__ is the method that sets up your object the moment it is created. Follow me Naveenthiran M U image generated using ChatGPT for Education #Python #OOP #LearnPython #Programming #Coding #Developers #SoftwareDevelopment #Tech #100DaysOfCode
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