example program on compositioncomposition class def add(self, , )self = self = print("the addition is:",self +self #composition class def sub(self, , )self = (#object of class (self = self = print("the subtraction is:",self -self yself add( , #calling the method of another class ob= (ob sub( , output the subtraction is the addition is the difference between inheritance and composition inheritance class inherits properties from another class the derived class may override base class functions the derived class may add data or functionality to the base class this represents "is-arelationship composition class contains objects of different classes as data members the container class cannot override the base class functions the container class cannot add anything to the contained class this represents "has-arelationship abstract classes and inheritances in pythonit is possible to create class which cannot be instantiated we can create class from which objects are not created this class is used as interface or template only the derived can override the features of the base class in pythonwe use "notimplementederrorto restrict the instantiation any class that has the notimplementederror inside the method definitions cannot be instantiated example program on abstract class#abstract class class adef disp(self)#abstract class method raise notimplementederror(class ( )def disp(self) page output the method of class the method of class