Methods in a Python class can be instance-level or class-level, similar to attributes.
An instance method is a method that is bound to an instance of a class. It can access and modify the instance data. An instance method is called on an instance of the class, and it can access the instance data through the self parameter.
A class method is a method that is bound to the class and not the instance of the class. It can’t modify the instance data. A class method is called on the class itself, and it receives the class as the first parameter, which is conventionally named cls.
Defining a class method is very convenient in Python. We can just add a built-in decorator named @classmethod before the declaration of the method.
Let’s see an example: