POLYMORPHISM: ============= Method Overloading: =================== m1(): implement-1 m1(): implment-2 m1(): implment-3 m1(): without arguments m1(self,a): with one parameter m1(self,a,b): with two parameters len(): len("Python") ==> 6 ==> total number of characters len(["Python","Abcde","Defghi""JKLMN"]) ==> 4 ==> count of number of string elements len({"abc":"pqr","def":"xyz","ghi":"lmn"}) ==> 3 ==> count of number of pair of strings ex: digital calculator: sum(): NO DATA sum = 0 sum(10) SUM = 10 SUM(10,20) SUM = 30 BNKING APPLICATION ROI SIMPLE COMPUND class Calculator: def addition(self,a = None,b = None,c = None,d = None,e = None): if a != None and b != None and c != None and d != None and e != None: print("The sum of 5 numbers = ",a+b+c+d+e) elif a!= None and b != None and c != None and d != None: print("The Sum of 4 numbers = ",a+b+c+d) elif a != None and b != None and c != None: print("The Sum 3 numbers = ",a+b+c) elif a != None and b != None: print("The Sum of 2 numbers = ",int(a)+int(b)) elif a != None: print("The Sum is = ",a) else: print("The Sum = ",0) cls = Calculator() cls.addition() # 0 parameters cls.addition(100) # 1 parameter cls.addition(121,122) cls.addition(111,222,333) cls.addition(12,24,36,48) ======================================== # method overloading class greetings: # def wish(self): # print("Good Morning") # def wish(self): # print("Good Afternoon") # def wish(self): # print("Good Evening") def wish(self,time = 0): if time > 0 and time < 12: print("Good Morning") elif time >= 12 and time < 16: print("Good Afternoon") elif time >= 16 and time < 20: print("Good Evening.") elif time >= 20 and time < 24: print("Good Night.") else: print("time Zone is searching..") # when the same method with three definitions, # the last definition is considered as the updated definition to execute. gt = greetings() gt.wish() # 0 parameters gt.wish(6) gt.wish(13) gt.wish(22) ===================================== Constructor Overloading: ======================= No constructor overloading is supported by the python. # constructor overloading class constructorOverloading: def __init__(self): print("Hello") def __init__(self,name): print("Hello",name) # obj = constructorOverloading() obj = constructorOverloading("Kumar")