top of page

Python class instance methods, class methods, and static methods

Updated: Jan 28, 2023

Python class can have 3 types of methods.


instance methods methods that are bound to an instance. Instance method called on an instance of the class, they can modify the state of the object. instance methods first parameter is self, with self parameter it can access the data of the object.


class methods methods that are bound to the class. A class method is called with the help of class_name only, they can't modify the instance data. class methods first parameter is cls by conventionally.


static methods methods that are not bound to the instance or the class. They are included in class, because they logically belongs to the class. usually static methods are defined as utility classes to perform a group of related tasks.



### OUTPUT
Employees count:  0
Nagesh, 78000.0     
Satish, 67000.0     
Employees count:  2 
employee deleted
Employees count:  1
Hike Details...
1-5 years, 30% HIKE
6-10 years, 25% HIKE
11-15 years, 10% HIKE
anyone, 5% HIKE
leaving __main__ scope. rest of the objects garbage collected.
employee deleted

Thanks for reading!!!

Your Rating and Review will be appreciated!!

Twitter: @LearnerLandmark

Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Commenting has been turned off.
bottom of page