Why class is used in python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0
30th Jun 2020, 2:56 PM
Umar Ansari
Umar Ansari - avatar
3 Answers
+ 2
In Simple Words Let’s Take Example Of A Classroom A Classroom Consist Of Number Of Student So All These Student Together Make A Class And Each Single Student Act As An Object Because Every Student Have Different Characteristics. So Multiple Object Come Together And Make A Class.
30th Jun 2020, 4:02 PM
Rahul Saxena
Rahul Saxena - avatar
+ 5
Take for example, when you code a game, there many types of objects, for example, enemies, and for each type of object, they all share same behavior (move, attack, etc.), but with different properties (hp, power, etc.) That's when we use Object Oriented Programming, instead of coding the enemies one by one, we create an instance of objects for each enemy.
30th Jun 2020, 3:06 PM
Gordon
Gordon - avatar