🔍 Explored something interesting while practicing OOP in Python While working on a simple cricket_player class, I wasn’t trying to learn anything new — just practicing. But during that, I noticed a small but important behavior. 👉 I used: >self.scores = [] to store player scores >add_score(score) to append values >avg_score() to calculate average 💡 What I realized: >The score inside add_score(score) is just a temporary value >But self.scores is the actual storage inside the object >Every time I call add_score(), I’m not passing data around — I’m updating the object’s internal state 📌 That means: The object itself keeps evolving as methods are called #Also noticed: >Even if I pass values as parameters elsewhere, the real source of truth remains self.scores >Functions can take inputs, but what matters is what part of the object they actually use This made me think of objects not just as structures, but as state containers that change over time Just a small observation from practice, but it clarified a lot. #Python #OOP #Programming #LearningByDoing #CodingJourney
Python OOP Practice: Objects as State Containers
More Relevant Posts
-
Thinking in Blueprints (Classes & Constructors) Focus: Introduction to OOP and the __init__ method. Day 9(06-04-2026): Today, my perspective on coding shifted. I moved away from just writing "steps" and started thinking in Objects. In Python, everything can be modeled after the real world using Classes. The big breakthrough today: Classes vs. Objects: A Class is the blueprint (like a drawing of a car), and the Object is the actual thing (the car you can drive). The Constructor (__init__): I learned how to use the "dunder init" method to give my objects their initial data the moment they are created. The self Keyword It’s a bit more abstract than what I’ve done before, but it makes the code so much more organized and powerful. #OOP #PythonProgramming #Day9 #ObjectOriented #CodingConcepts
To view or add a comment, sign in
-
🚀 Built a Python Quiz Game Engine: Here’s What I Learned I recently developed a fully functional Quiz Game Engine in Python designed with scalability, clean architecture, and real world usability in mind. 🔍 Key Highlights: Multiple question types (Q&A, MCQ, True/False) Time-based answering system using multi-threading JSON Schema validation for structured data integrity Automated scoring + CSV-based result tracking Modular and type-safe code design This project pushed me to think beyond “just making it work” focusing instead on: ✔ Clean architecture ✔ Input validation ✔ Real-world usability ✔ Performance under constraints (timers) 💡 One interesting challenge: implementing a thread-safe timer system without external libraries. If you're learning Python, don’t just build scripts build systems. 🔗 Check it out: https://lnkd.in/deba_WM7 #Python #SoftwareEngineering #OpenSource #Projects #LearningByDoing #Programming
To view or add a comment, sign in
-
-
Week 3 of #100DaysOfCode — done! 🎉 This week I started thinking in objects. Topics covered: 🧱 Classes & Objects → What OOP actually is (and why it matters) → Classes, instances, attributes, methods → public, _protected, and __private attributes → __init__, self, and how Python works under the hood 🔒 Properties → @property — the Pythonic way to write getters & setters → No more get_age() / set_age() — just person.age ✅ ⚙️ More Classes → __str__ vs __repr__ — and why both matter → Class attributes vs instance attributes → @classmethod and @staticmethod → __dict__, getattr, dynamic attributes I’ve structured my learning into notes and practical examples to better understand the concepts : https://lnkd.in/epaBymnJ 21 days down. 79 to go. 💻 #100DaysOfCode #Python #LearningInPublic #Programming
To view or add a comment, sign in
-
Day 02 of my #30DaysOfPython journey was all about the fundamentals that make everything else easier to understand. 🐍 Today I visited three important basics: 🔹 Built-in functions Python comes with a bunch of functions ready to use right away — no extra setup needed. A few examples: print(), len(), type(), int(), str(), float(), list(), dict(), sorted() 🔹 Reserved words Some words are already taken by Python and cannot be used for variable or function names. Examples include: false, true, class, def, if, assert 🔹 Variables Variables are basically labels for storing data in memory. One thing I found useful today is that variable names should actually make sense — no random names, no numbers at the start, and no special characters or hyphens. I also learned that assigning a value to a variable is called variable declaration, and multiple variables can even be declared in a single line. And finally, input() is what makes programs interactive by letting us take input from the user. A simple topic, but one that matters a lot. The basics may look small, but they quietly shape everything that comes next. Github Link - https://lnkd.in/gUQvkhyz #Python #30DaysOfPython #LearningInPublic #Programming #SoftwareDevelopment #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
-
Day 5 of my Python learning journey — diving deeper into OOP Today I implemented two core classes: BankAccount and InventoryItem, with a focus on clean design and proper encapsulation. A key takeaway: Validate first, then modify state — never the other way around. I also caught a few common pitfalls early: • Exposing internal attributes directly • Performing validation after state changes • Duplicating logic across methods This exercise reinforced an important principle: a well-designed class should be self-protecting. External code should interact with it safely through defined interfaces, without risking inconsistent state. Feeling more confident with structuring real-world logic using classes and applying these concepts in API design with FastAPI. GitHub Repository: https://lnkd.in/dqBZtfpM #Python #OOP #FastAPI #SoftwareEngineering #CleanCode #LearningInPublic
To view or add a comment, sign in
-
-
Today’s Python topic felt like the point where code stops being one-time work and starts becoming reusable. 🐍 Day 11 of my #30DaysOfPython journey was all about the basics of function, and this one was a big reminder that good code is not just about writing more — it is about writing smarter. A function is a reusable block of code designed to do a specific task, and in Python, we define it using the def keyword. Today I explored: 1. How functions are created and called 2. How return sends values back from a function and return None when nothing is returned 3. Passing parameters and arguments 4. Passing arguments using key-value style 5. Default parameters 6. Arbitrary arguments with *args 7. Arbitrary named arguments with **kwargs What stood out to me today was how functions make code feel organized, reusable, and much easier to scale. Instead of repeating the same logic again and again, you write it once and use it wherever needed. One more day, one more topic, one more step toward writing code that is cleaner, smarter, and actually built to last. Github Link - https://lnkd.in/gUhhaW_y #Python #LearnPython #CodingJourney #30DaysOfPython #Programming #DeveloperJourney
To view or add a comment, sign in
-
I’ve been using Jupyter notebooks for years, but they tend to get messy once they stop being "temporary". I recently tried marimo, and it feels like a different approach: • notebooks as plain Python files • dependency-based execution (no more weird states) • much cleaner to keep in git What I like most is that it sits somewhere between a notebook and a small app. I also show a real example: using it to recover deleted S3 files. 👉 https://lnkd.in/d_YdRCbd
To view or add a comment, sign in
-
🚀 Day 8 of My Python Learning Journey Today, I built a Menu-Driven Calculator Program in Python 🧮 💡 What I learned & implemented: Creating functions (def) for reusable code Performing operations like Addition, Subtraction, Multiplication, Division, and Average Using conditional statements to control program flow Taking user input for dynamic calculations 🧠 Mini Project: Calculator Program I designed a calculator that allows users to: ✔ Select an operation from a menu ✔ Input numbers ✔ Get results instantly 📌 Functions Created: add() → Addition sub() → Subtraction multiply() → Multiplication (and more...) 🔍 Key Learning: Breaking a problem into smaller functions makes the code cleaner, reusable, and easier to manage. 💭 This is helping me build a strong foundation for writing scalable and structured programs. 🚀 Next Step: Loops & Advanced Logic Implementation https://lnkd.in/gJrKBVi3 #Python #LearningJourney #100DaysOfCode #Coding #DataAnalytics #Functions #ProblemSolving
To view or add a comment, sign in
-
Built a simple File Reader CLI in Python today. This project takes a file path as input, opens the file, reads its contents, and prints everything directly in the terminal. What I learned while building it: • Taking user input with input() • Opening files using open() • Reading file content with read() • Using with for safe file handling • Adding error handling with try/except Small projects like this are helping me strengthen my Python fundamentals and get more comfortable with writing clean, practical code. GitHub Repository: https://lnkd.in/gud495tr #Python #PythonProjects #CLI #CodingJourney #Programming #LearningInPublic
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