+ 1

What are classes and objects?

Hello everyone! I’m learning Python for a few months, and I know basically everything except Classes and Objects. What are they? Are they connected to each other? Every explanation will be welcome! Thanks.

22nd Apr 2018, 3:57 AM
Tomer Shechner
Tomer Shechner - avatar
4 Answers
+ 3
Classes: class is the blue print of our object.basically class tell you how is our object.In class you add some attributes.these attributes belong to object.means object should be all attributes of class.by defining class you can do anything with your object which is defined in class. object:- we create object to use our class. e.g= class Car: def__init__(self,speed,colour) self.s=speed self.c=colour y=Car(250,red) print(y.s) # output=250 ----------------------- where y is object.In class self means object name.
22nd Apr 2018, 4:39 AM
Maninder $ingh
Maninder $ingh - avatar
+ 2
Consider an animal as a class and type of animal like dog or cat can be considered as an object which has properties like size, color, strength, height etc. Basically classes are for grouping the similar things or requirements which are related to functionality of that class. These functionalities can be implemented using objects. Hope this is helpful
22nd Apr 2018, 4:26 AM
kaliki chandu
kaliki chandu - avatar
5th May 2018, 9:44 AM
Johannes
Johannes - avatar
0
thank you very much you two
22nd Apr 2018, 10:14 AM
Tomer Shechner
Tomer Shechner - avatar