Why dealing with Python Classes is so different from most languages such as C++ or JAVA? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why dealing with Python Classes is so different from most languages such as C++ or JAVA?

Those of you programming in JAVA and C++ take a look at Python classes!

26th Apr 2018, 1:05 AM
Luther Conley
1 Answer
0
The class describes what the object will be, but is separate from the object itself. In other words, a class can be described as an object's blueprint, description, or definition. You can use the same class as a blueprint for creating multiple different objects. Classes are created using the keyword class and an indented block, which contains class methods (which are functions). Below is an example of a simple class and its objects. class Cat: def __init__(self, color, legs): self.color = color self.legs = legs felix = Cat("ginger", 4) rover = Cat("dog-colored", 4) stumpy = Cat("brown", 3)
26th Apr 2018, 1:20 AM
Luther Conley