1# Instance Method Example in Python
2class Student:
3
4 def __init__(self, a, b):
5 self.a = a
6 self.b = b
7
8 def avg(self):
9 return (self.a + self.b) / 2
10
11s1 = Student(10, 20)
12print( s1.avg() )
1# Class Method Implementation in python
2class Student:
3 name = 'Student'
4 def __init__(self, a, b):
5 self.a = a
6 self.b = b
7
8 @classmethod
9 def info(cls):
10 return cls.name
11
12print(Student.info())
1# Static Method Implementation in python
2class Student:
3 name = 'Student'
4 def __init__(self, a, b):
5 self.a = a
6 self.b = b
7
8 @staticmethod
9 def info():
10 return "This is a student class"
11
12print(Student.info())
13