WHY STATIC METHODS? =================== static methods allows you to isolate the utility methods into different sub-modules (classes). @staticmethod def staticmethod(): implement Ex: phonepe: class sending money: class mobile: mobile : XXXXXXXX amount : 100000 UPI : XXXX balance() class UPI: class account: class check balance: @ staticmethod def balance(): implementation upi fetch ==> Bank display class1: def m1(): instance method @staticmethod def m2(): static method class2: m1() ==> Error m2() ==> correct ================================= Class Method: ============= class method can always define with: class variables. @classmethod ==> can always invoke with only the class name. Syntax: class-name.methodname() class Animal: legs = 4 @classmethod def met1(cls,name): print("{} walks with {} legs.".format(name,cls.legs)) def met2(self): print(self.legs) Animal.met1("cow") ==> class method is a built-in method in python that is used to define a method that is bound to the class and not the instance of the class. ================================================= Setter and Getter Methods: ========================== Setter method ==> set the values for instance variables Getter method ==> get the value of instance variable Why: ==== for Encapsulation of the data. Setter Method: ============== Syntax: def setVariable(self, variable): self.variable = variable Getter Method: ============== Syntax: def getVariable(self): return self.variable class Student: def setName(self,name): self.name = name def getName(self): return self.name def setRoll(self,roll): self.roll = roll def getRoll(self): return self.roll stu1 = Student() stu1.setName("Venkat") return1 = stu1.getName() print(return1) stu1.setRoll(101) print(stu1.getRoll()) ======================================== Inner Class: ============ writing of one class inside the other class also called as "nesting of class" class Phonepe: class send money: implementation class check balance: implementation class chat: implementation class outerClass:# parent class def __init__(self): print("Outer class object creation...") class innerClass:# inner class def __init__(self): print("Inner Class Object creation....") def m1(self): print("Inner class method.") class inner: def __init__(self): print("Another Inner Class.") def m2(self): print("m2 is calling.") obj = outerClass() # creation of an object for the inner class # using parent's class object cobj = obj.innerClass() cobj.m1() acobj = obj.inner() acobj.m2()