+ 2
How to better understand OOP section in Python and in general?
I used to understand the sololearn lessons, but this one made me stuck :(
3 Respostas
+ 2
try and think of a class as an actual general object. Like a car, a house, or even a person.
Each of those things has attributes.
A car has a make and model, a house has rooms and square feet, and people have too many to list a few.
All OOP does is represent that in code.
Every one of those things also has actions/changes that occur. Cars honk and accelerate, houses are bought and sold, people again, do too many things. But you can consider all those as methods.
An instance of a class is just an induvidual object. ex. That house over there. Its attributes are 3 rooms 1 bathroom. Oh look, the market just went up and the house gained value! A weird way of saying it but it gets the point across
+ 1
Yeah. OOP in Python can be different from what you know it to be in other languages but the concepts are basically the same. Just read a good article or book about OOP like this one.
https://www.freecodecamp.org/news/object-oriented-programming-concepts-21bb035f7260/amp/
When you grok the concepts, try to relate it with the Python OOP tutorial.