Inheritance python

 Inheritance python

        It is used to achieve concept of re-usability. inshort, inheritance means to take something that already made.

class MobileA:
def fun1(self):
print("Function 1 working")
def fun2(self):
print("function 2 working")
class MobileB(MobileA): #Child class/sub class
def fun3(self):
print("function 3 working")
def fun4(self):
print("function 4 working")
class MobileC(MobileB):
def fun5(self):
print("Function 5 working")
def fun6(self):
print("function 6 working")
m1=MobileA()
m1.fun1()

m2 = MobileB()
m2.fun2()

m3 = MobileC()
m3.fun2()
Output
Function 1 working
function 2 working
function 2 working

Types of inheritance

  1. Single level inheritance 
  2. Multilevel inheritance