Multiple inheritances
At the point when we have one youngster class and more than one parent classes then it is called numerous legacy for example at the point when a kid class acquires from more than one parent class.
In this program, we have two parent classes Personel and Educational and one kid class named Student and executing numerous legacy.
Python code to demonstrate an example of multiple inheritances
# Python code to demonstrate example of
# multiple inheritance
class Personel:
def __init__(self):
self.__id=0
self.__name=""
self.__gender=""
def setPersonel(self):
self.__id=int(input("Enter Id: "))
self.__name = input("Enter Name: ")
self.__gender = input("Enter Gender: ")
def showPersonel(self):
print("Id: ",self.__id)
print("Name: ",self.__name)
print("Gender: ",self.__gender)
class Educational:
def __init__(self):
self.__stream=""
self.__year=""
def setEducational(self):
self.__stream=input("Enter Stream: ")
self.__year = input("Enter Year: ")
def showEducational(self):
print("Stream: ",self.__stream)
print("Year: ",self.__year)
class Student(Personel,Educational):
def __init__(self):
self.__address = ""
self.__contact = ""
def setStudent(self):
self.setPersonel()
self.__address = input("Enter Address: ")
self.__contact = input("Enter Contact: ")
self.setEducational()
def showStudent(self):
self.showPersonel()
print("Address: ",self.__address)
print("Contact: ",self.__contact)
self.showEducational()
def main():
s=Student()
s.setStudent()
s.showStudent()
if __name__=="__main__":main()
Output
Enter Id: 101
Enter Name: Prem Sharma
Enter Gender: Male
Enter Address: Nehru Place, New Delhi
Enter Contact: 0123456789
Enter Stream: Computer Science
Enter Year: 2010
Id: 101
Name: Prem Sharma
Gender: Male
Address: Nehru Place, New Delhi
Contact: 0123456789
Stream: Computer Science
Year: 2010