Class and Objects in Python

We are well known Python is Object Orientd Programming Language.

class represents a group of similar objects to represents a classes in python user-defined datatype.
A class is describe all the properties of a datatype,and object is entity created according to that discription.
class is a keyword used to create a class.

Syntax of creating a class

class:
    #statement
	#statement
	#statement
Example
class SmallCode:
    x="Small Code"
print(SmallCode)

Output

<class '__main__.SmallCode'>

Object

Object is a real world,physical entity such as pen, computer, mobile, table, keyboard, mouse,book etc. It is also instance of a class.
We can create zero or more object as per requirement.

Difference between Object and class

Class

Object

Class is a blueprint or template from which objects are created.

Object is an instance of a class.

It is a group of similar objects.

It is a real world entity such as mobile,car,book,laptop,chair etc.

It doesn't allocated memory when it is created.

It allocates memory when it is created.

Class is declared once.

We can create zero or more object as per requirement.

Syntax

class class_name:
    #statement 

Syntax

object_var=class_name(value_if_any)
Example
class sc:
    x="SmallCode"
Example
class sc:
    x="SmallCode"
obj=sc()
print(obj.x)