Week 4 of #100DaysOfCode — done! 🎉 Last week I learned how to build classes. This week I learned how to make them talk to each other. Topics covered: 🧹 Inheritance → Superclass, subclass, base class — and what they actually mean → How Python finds attributes (spoiler: it walks up the chain) → Overriding methods — and extending them with super() → isinstance, issubclass, type — when to use which → Multiple inheritance + MRO (Method Resolution Order) 🏗️ Abstract Classes & Interfaces → ABC + @abstractmethod — enforcing a contract on subclasses → Duck typing — "if it has a speak() method, it speaks" → Subclassing built-ins (list, dict, iterator) → Mixins — plugging in behaviour without full inheritance I’ve structured my learning into notes and practical examples to better understand the concepts : https://lnkd.in/epaBymnJ #100DaysOfCode #Python #OOP #LearningInPublic #Programming
Week 4 of #100DaysOfCode: OOP with Inheritance & Abstract Classes
More Relevant Posts
-
🐍 Day 8 of Learning Python — and things are getting real! Today's lab was all about writing code that doesn't break (or at least fails gracefully 😄). Here's what I worked through: ✅ Exception Handling — try / except / else / finally • Caught ZeroDivisionError, FileNotFoundError, ValueError, and TypeError • Used `raise` to throw custom error messages • Built my own exception class: TooSmallError 🎉 ✅ Standard library deep dive: • math — calculated circle areas, factorials, GCD, and compound interest • random — shuffled lists, simulated 1000 coin flips, generated reproducible sequences with seed() • datetime — parsed date strings, added time deltas, sorted ISO dates, and printed 5-day schedules ✅ Introspection with dir() and help() The biggest lesson today? Real-life programs don't always get perfect input. Learning to handle errors gracefully is just as important as writing the happy path. Day by day, the pieces are coming together. 💪 #Python #100DaysOfCode #LearningToCode #PythonProgramming #CodingJourney #Day8
To view or add a comment, sign in
-
📅 7 April 2026 Solved Median Finder (Two Heaps) problem today on LeetCode. Initially, I was getting wrong answers even though the logic looked correct. The mistake? Comparing directly with a max heap stored as negative values. 🔍 Key Learning: When using a max heap in Python (via negative values), always convert back before comparison. ❌ Wrong: num < self.left[0] ✅ Correct: num <= -self.left[0] 💡 Approach: - Use two heaps: • Max Heap (left) → stores smaller half • Min Heap (right) → stores larger half - Balance both heaps after every insertion - Median depends on heap sizes 📈 Time Complexity: - addNum → O(log n) - findMedian → O(1) Small bug, big learning 🚀 Consistency in DSA is what builds clarity. #leetcode #dsa #python #heaps #codingjourney #problemSolving
To view or add a comment, sign in
-
-
Just solved “Second Largest Digit in a String” on LeetCode — and here’s the simple approach I followed 👇 Instead of overcomplicating it, I focused on clean thinking + Python basics: 🔹 Converted the string into a set → removes duplicates instantly 🔹 Filtered only digits using isdigit() 🔹 Stored them as integers in a list 🔹 Sorted the list → easy access to largest & second largest 🔹 Edge case check: if less than 2 digits → return -1 💡 Key takeaway: Sometimes the most optimal solution isn’t about complex algorithms — it’s about using the right built-in tools smartly. 🚀 What I’m improving with each problem: • Writing cleaner logic • Thinking in steps instead of rushing • Handling edge cases early Consistency > Complexity. #LeetCode #DSA #Python #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Today’s Python lesson made the whole language feel more connected. 🐍 Day 12 of my #30DaysOfPython journey was all about modules, and this one felt like learning how Python organizes its tools behind the scenes. A module is basically a file that contains code, functions, or variables that you can reuse in another file. Instead of writing everything from scratch, you can create something once and bring it into your main program whenever needed. Today I explored: 1. What modules are and why they matter 2. Creating a separate file and importing it into another file 3. Importing only specific parts instead of the whole file 4. Renaming something while importing it 5. Built-in modules like os, statistics, math, string, and random What stood out to me today was how modules make Python feel less like a single script and more like a system of connected pieces. That shift matters because it is what makes code easier to reuse, organize, and scale. One more day, one more topic, one more step toward writing code that is cleaner, smarter, and more modular. Which felt more useful to you first: creating your own module or using built-in ones like math and os? Github Link - https://lnkd.in/gVPWQWiS #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
To view or add a comment, sign in
-
💻 Solved a great problem today: Count Increasing Subarrays 🚀 Given an array, the task was to count all strictly increasing subarrays of size ≥ 2. 🔍 Approach I used: Broke the array into continuous increasing segments For each segment of length k, calculated subarrays using the formula: 👉 k(k-1)/2 Summed all results to get the final answer ⚡ Time Complexity: O(n) 📦 Space Complexity: O(n) 💡 This problem helped me understand how breaking a problem into patterns can simplify complex logic. Here’s my Python solution 👇 class Solution: def countIncreasing(self, arr): list2 = [] list2.append(arr[0]) list3 = [] for i in range(1, len(arr)): if arr[i-1] < arr[i] and arr[i] > 2: list2.append(arr[i]) else: list3.append(list2) list2 = [] list2.append(arr[i]) list3.append(list2) ans = 0 for i in list3: if len(i) > 1: ans += (len(i) * (len(i) - 1)) // 2 return ans 🔥 Always learning, always improving. #python #dsa #coding #problemSolving #programming #developers #learning
To view or add a comment, sign in
-
-
Day 18 revision done. Operators. If/Else. Match statements. While loops. For loops. Not just reading through notes this time actually writing the code out, making mistakes, fixing them and doing it again until it felt natural. And honestly? It's working. The things that confused me the first time around are starting to make sense now. I finally get why // and % are different. I understand why indentation is not optional in Python. I know when to use a while loop vs a for loop. Revision isn't glamorous. There's no big aha moment. It's just you sitting down, doing the work and trusting that repetition builds confidence. And slowly it is making sense It is finally sticking and guess what I'm happy. Because Python is one of the most amazing tools used in the data space and I'm out here learning it on my own. Day 19 is next. Let's keep going. #Python #100DaysOfCode #SelfTaught #GrowthMindset #DataAnalysis #W3schools
To view or add a comment, sign in
-
Most of the code I’ve written works. That doesn’t mean it’s good. I won a book at a recent Python x Data Science taster session hosted by SkillStruct University and it’s already shifted how I think. Powerful Python: Patterns and Strategies with Modern Python introduces a different way of approaching code. It’s not about if the code runs, but rather thinking about structure and efficiency. I’ve only just started it, but one concept that stood out is generator functions. At first, I saw it as a useful shortcut to create iterators. But it’s more than that. Instead of building and storing everything upfront, you generate values only when needed. A small shift. But it completely changes how you think about performance. Especially when working with larger datasets. It made me realise how often I focus on getting something to work… rather than thinking about how it should be built. Still early into the book but definitely something I want to explore and apply in my projects. What’s a concept that changed how you approach learning? Thanks to Michael Olatokun for the book. #Python #DataScience #Programming #SoftwareDevelopment #LearningInPublic #TechCareers #CodingJourney
To view or add a comment, sign in
-
-
At first, I thought creating classes was enough… but then I realized—real power comes from building on top of them. Today’s Python MahaRevision 🧬 Chapter 11: Inheritance & More in OOP This chapter took things a step deeper: → Inheritance (reusing and extending existing classes) → Types of inheritance → Method overriding → Using super() → Exploring more OOP concepts It actually felt like connecting pieces together instead of starting from scratch every time. Practice set done: Worked on creating parent-child classes, modifying behaviors, and experimenting with inherited properties and methods. Biggest takeaway You don’t always need to build everything new—sometimes the smartest approach is to reuse and improve what already exists. Slowly understanding how real-world applications are structured. One step at a time. #Python #LearningInPublic #CodingJourney #Programming #OOP
To view or add a comment, sign in
-
Recursion confused me. So I built a visualizer for it. 🐍 Most beginners (including me) struggle with one thing: "What actually happens when a function calls itself?" So I wrote a Python program that shows you — step by step, with a delay so you can actually follow it. Watch it go DOWN the stack, hit the base case, then come back UP — adding numbers on the way. 👇 What I used: → Recursion — function calling itself → time.sleep() — to slow execution down visually → Print statements — to trace every step This isn't from a tutorial. I built this because I was confused. That's the best reason to build anything. 💡 Important: Dry run your code, It helps alot. #Python #Recursion #LearningInPublic #DataAnalytics #BBA #BuildInPublic
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