
#Types of methods: 1. Instance method 2. Class method 3. Static method
class Student:
institute='Oxford'
def __init__(self, m1, m2, m3):
self.m1=m1
self.m2=m2
self.m3=m3
def avg(self): #instance method - passing self
return (self.m1+self.m2+self.m3/3)
@classmethod #decorators
def info(cls): #class method
return cls.institute
def get_m1(self): #accessor method
return m1
def set_m1(self, value): #mutator method
self.m=value
@staticmethod
def method2():
print("This is a student class")
s1=Student(20,23,25)
s2=Student(25,24,22)
print(s1.avg())
print(s2.avg())
print(Student.info())
Student.method2()
#Instance method is of 2 types: 1. Accessor method - only fetch values 2. Mutator Method - Modify values
#To access class variable use class method
#Class method uses cls as agrument
#Class method is same for all object, so use class name to call class method
#A Static method is a method that does not using the class variable nor instance variable
Ad: