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

Comments

Rated 0 out of 5 stars.
No ratings yet

Commenting on this post isn't available anymore. Contact the site owner for more info.

#7-1-619/A/3/B, Plot No 48, SAP street, Gayathri Nagar, Behind Maitrivanam, Hyderabad 500 038.

Subscribe Form

Thanks for submitting!

91 9693996999

Python Interview Questions | Python Interview Questions for freshers |  Python Coding Questions and Answers | python programming interview questions | python technical interview questions |  python interview questions and answers for experienced | python basic interview questions and answers | Python coding questions |  Top Python interview questions

  • Youtube
  • Facebook
  • Twitter
  • LinkedIn

©2023 by Learner Landmark. All Rights Reserved.

bottom of page