Inheritance in Python
As we all know Inheritance is ‘One class can acquire the properties of another class’. We can extend one class by another class in python also. Following example demonstrate how can we use inheritance in Python.
class University:
def __init__(self,nm=None):
self.uniname=nm
def showUni(self):
print("University ",self.uniname)
class College(University):
def __init__(self,uniname,colname):
super().__init__(uniname)
self.nm= colname
def showCol(self):
print("College :",self.nm)
C= College("GTU","LD")
C.showUni()
C.showCol()