Tuesday, 24 November 2020

Inheritance in Python

 

 

 #Multiple Inheritance

class Father:
    def reading1():
        Father.height1=int(input("Enter Fathers Height"))
    def printing1():
        print("Fathers height: ",Father.height1)
class Mother:
    def reading2():
        Mother.height2=int(input("Enter mothers Height"))
    def printing2():
        print("Mothers height: ",Mother.height2)
class child(Father,Mother):
    def calculate():
        child.height3=(Father.height1+Mother.height2)/2
    def printing():
        print(child.height3)
Father.reading1()
Father.printing1()
Mother.reading2()
Mother.printing2()
child.calculate()
child.printing()       

OUTPUT:


No comments:

Post a Comment