Family Tree with Hybrid Inheritance Python || Type -1 || Hybrid Inheritance || Python
In this we are going to see a basic program on family tree with hybrid inheritance type 1 in Python Programming Language.


class Grandparent:
    gparentname = ""
    def show_gparent(self):
        print("GrandParent:",self.gparentname)


class Father(Grandparent):
    fathername = ""
    def show_father(self):
        print("Father:",self.fathername)


class Mother(Grandparent):
    mothername = ""
    def show_mother(self):
        print("Mother:",self.mothername)


class Child(Father,Mother):
    childname = ""
    def show_child(self):
        print("Child:",self.childname)


ch1 = Child()
ch1.gparentname = "Tom"
ch1.fathername = "Mark"
ch1.mothername = "Lily"
ch1.childname = "John"
ch1.show_gparent()
ch1.show_father()
ch1.show_mother()
ch1.show_child()

# Coded by Saahil

#ENJOY CODING


Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post