r/PythonLearning • • Oct 09 '26

Do I really need to learn class.

Post image

Both function and class give the same output. So why do I need it?

70 Upvotes

50 comments sorted by

View all comments

1

u/TemperatureProper275 Oct 13 '26

Its a consept that re-uses code and is more understanble for more complex design.

For example, lets suppose you have a class called vihecle. A vehicle can be a car, a motorcycle ans so on.

Most of the vihecles have attributes like enginet type, engine size, HP and so on.

When you set a constuctor with some initialized data this data then can be inherited from the Childer thus minimizing code and having a better overall structure.

In python you can work with both OOP approach and Function Based approach.

To underastand it better, convert any project you have done without OOP to a projects that is OOP based.

Sure there are things that needs more time to learn, but you learn by building!