Articles
The problem...
You've built three projects. Each one works. Each one has functions that add data, filter data, display data, export data.
But look at the Calories Tracker. add_f…
The idea
A class is a blueprint. An object is what you build from it.
The blueprint for a house defines how many rooms it has, where the door is, what materials it uses. The hou…
The idea
Every object has two things: data it holds and actions it can perform.
The data is stored in attributes. The actions are defined as methods.
You've already seen both &…
The problem...
You've seen self in every method. You've written it without fully understanding it. It's always the first parameter. Python seems to handle it automatically. But w…
The problem...
You have an Animal object. Status starts as "available". At some point in your code — or someone else's — this happens:
lassie.status = "missing"
las…
The problem...
You have an Animal class. It works well for the Safe Paws shelter — name, species, size, health, status.
Now you want a Dog class and a Cat class. Dogs have…