+ 2

What are classes in python?

I went through sololearn python course and i found i easy to understand all concepts till i came to classes, it bothers me because I don't understand it. . If any one could explain it her i will be thankful

25th Jan 2018, 9:34 PM
Ahmed Kamal
Ahmed Kamal - avatar
1 Resposta
+ 1
A class is basically a container that has both data and behaviour (methods). Using classes you can model real life items in code. When modelling an administration for furniture you can have: - a class named Administration that maintains a list of furniture. So it has the mentioned list as data and stuff like AddItem(...), RemoveItem(...) and so on as behaviour. - a class named furniture that has generic data and methods for all furniture. Generic data can be stuff like a date on which you bought the item and what its price was - a subclass table that inherits from furniture that adds the number of legs and material to the base class. Does that help? Did you read through https://en.wikipedia.org/wiki/Class_(computer_programming)? Maybe that helps too?
25th Jan 2018, 9:59 PM
Freddy