Day13
1 min readSep 23, 2019
Multiple Inheritance : In this type of inheritance have two parents classes invoking in single child class.
Example :
class Run:
def __init__(self, total_run):
self.total_run = total_run
def run(self):
return "{}".format(self.total_run)
class Wicket:
def __init__(self, total_wicket):
self.total_wicket = total_wicket
def loss_wicket(self):
return "{}".format(self.total_wicket)
class Score(Run,Wicket):
def __init__(self):
Run.__init__(self, 210)
Wicket.__init__(self, 9)
score1 = Score()
print(score1.loss_wicket())
print(score1.run())
Multi-level Inheritance : In multiple inheritance one child class can inherit multiple parent classes.
Example:-
class student:
def get_Student(self):
self.name = input("Name: ")
self.age = input("Age: ")
self.gender = input("Gender: ")
class test(student):
def get_Marks(self):
self.student_Class = input("Class: ")
print("Enter the marks of the respective subjects")
self.literature = int(input("Literature: "))
self.math = int(input("Math: "))
self.biology = int(input("Biology: "))
self.physics = int(input("Physics: "))
class marks(test):
def display(self):
print("\n\nName: ",self.name)
print("Age: ",self.age)
print("Gender: ",self.gender)
print("Study in: ",self.student_Class)
print("Total Marks: ", self.literature + self.math + self.biology + self.physics)
m1 = marks()
m1.get_Student()
m1.get_Marks()
m1.display()