• Chennai, Bangalore & Online: 93450 45466Coimbatore: 95978 88270Madurai: 97900 94102

  • Types Of Inheritance In Python

    Let’s discuss the following things in this blog.

    What is inheritance
    Types in inheritance
    Single Level Inheritance
    Multi-Level Inheritance
    Multiple Inheritance
    Hierarchical Inheritance
    Hybrid Inheritance
    The __init__ method
    super() charge method

    You might have some resemblance or inherited behaviours or traits in you from your family’s lineage. Just like this, you can inherit properties of one class from another one.The newly inherited class is a child or derived class and the former as parent or base class.Inheritance emphasizes the DRY(Don’t Repeat Yourself) rule, with code reusability.

    Here is an example of Inheritance

    class Parent:

       def func1(self):

           print(“I am in parent class”)

    class Child(Parent):

        def func2(self):

           print(“I am in derived class”)

    obj = Child()



    Single Level Inheritance

    Check out this Complete Online Python Course by FITA. FITA provides a complete Python course where you will be building real-time projects like Bitly and Twitter bundled with Django, placement support and certification at an affordable price.

    In single level inheritance, there is only one child or derived class from a parent or base class.The example below is a one to one relation between base and a derived class.

    class Article:

        def __init__(self, title, content, author):

             self.title = title

             self.content = content

             self.author = author

        def represent(self):

              return f'{self.author}is an author of 


    Class Post(Article):

         def __init__(self, title,content,author):


    art_1 = Article(‘Automate the Boring Stuff’,

                        ‘Practical Programming..’,

                        ‘AL Sweigart’)

    art_2= Post(‘Python Tricks’,

                        ‘A Buffet of Awesome Python..’,

                        ‘Dan Bader’,’book.jpg’)

    The __init__ method

    You might have noticed the __init__ method in the above program. Such prefixed and postfixed double unscored methods are known as magic methods or dunder methods. This method is a constructor or initializer for attributes.A class recognizes its attributes with the self keyword.

    The super() method

    The super().__init__ method calls the constructor for the Base class with defined parent class attributes i.e., you can use parent class attributes and methods in the Base class.

    Passing an argument of class name as base class to a derived class is known as subclassing.By this the derived class identifies its base class.

    Multiple Inheritance

    In multiple inheritance, a child class has more than one parent class.Here’s an example

    class Father:

        def func1(self):

              print(“I am your dad!”)

    class Mother:

        def func2(self):

             print(“I am your mom!”)

    class Child(Father, Mother):

        def func3(self):

             print(“Hi mom and dad”)

    ob = Child()




    Multilevel Inheritance

    A Multi-level instance is when a derived class is a base class for another class. For instance , like this

    class Father:

        def func1(self):

             print(“this is your father”)

    class Son(Father):

        def func2(self):

             print(“this is your son”)

    class GrandSon(Son):

        def func3(self):

             print(“this is your grandson”)

    obj = GrandSon()




    Hierarchical Inheritance

    Hierarchical Inheritance involves multiple inheritances from the same Parent or Child classes.

    class Parent:

            def func1(self):

                 print(“I am your Dad”)

    class FirstSon(Parent):

            def func2(self):

                 print(“I am the eldest brother”)

    class SecondSon(Parent):

            def func3(self):

                 print(“I am the youngest brother”)

    obj1 = FirstSon()

    obj2 = SecondSon()



    Hybrid Inheritance

    Hybrid Inheritance is when there is multiple and multilevel inheritance in a particular program.

    class GrandParent:

            def func1(self):

                 print(“I am Your grandpa!”)

    class Father(GrandParent):

            def func2(self):

                 print(“I am your father!”)

    class Uncle(GrandParent):

            def func3(self):

                  print(“I am your uncle!”):

    class GrandSon(GrandParent , Father):

            def func4(self):

                 print(“I am the youngest son.”)

    obj = GrandSon()


    This was all about Inheritance and its types, applications and implementation in python.There is a lot more covered about this topic in Online Python Course. More over there is also an on campus version of this course as Python Training in Chennai or Python Training in Bangalore by FITA at an affordable price, which includes real time projects ,certification, support and career guidance assistance.

    Quick Enquiry

    Please wait while submission in progress...

    Contact Us


      93450 45466


     93450 45466


     95978 88270

    For Hiring

     93840 47472

    Corporate Training

     90036 23340

    FITA Academy Branches

    Other Locations
    FITA Academy - Velachery
    Plot No 7, 2nd floor,
    Vadivelan Nagar,
    Velachery Main Road,
    Velachery, Chennai - 600042
    Tamil Nadu

        :   93450 45466

    FITA Academy - Anna Nagar
    No 14, Block No, 338, 2nd Ave,
    Anna Nagar,
    Chennai 600 040, Tamil Nadu
    Next to Santhosh Super Market

        :   93450 45466

    FITA Academy - T Nagar
    05, 5th Floor, Challa Mall,
    T Nagar,
    Chennai 600 017, Tamil Nadu
    Opposite to Pondy Bazaar Globus

        :   93450 45466

    FITA Academy - Tambaram
    Nehru Nagar, Kadaperi,
    GST Road, West Tambaram,
    Chennai 600 045, Tamil Nadu
    Opposite to Saravana Jewellers Near MEPZ

        :   93450 45466

    FITA Academy - Thoraipakkam
    5/350, Old Mahabalipuram Road,
    Okkiyam Thoraipakkam,
    Chennai 600 097, Tamil Nadu
    Next to Cognizant Thoraipakkam Office and Opposite to Nilgris Supermarket

        :   93450 45466

    FITA Academy - Porur
    17, Trunk Rd,
    Chennai 600116, Tamil Nadu
    Above Maharashtra Bank

        :   93450 45466

    FITA Academy Marathahalli
    No 7, J J Complex,
    ITPB Road, Aswath Nagar,
    Marathahalli Post,
    Bengaluru 560037

        :   93450 45466

    FITA Academy - Saravanampatty
    First Floor, Promenade Tower,
    171/2A, Sathy Road, Saravanampatty,
    Coimbatore - 641035
    Tamil Nadu

        :   95978 88270

    FITA Academy - Singanallur
    348/1, Kamaraj Road,
    Varadharajapuram, Singanallur,
    Coimbatore - 641015
    Tamil Nadu

        :   95978 88270

    FITA Academy - Madurai
    No.2A, Sivanandha salai,
    Arapalayam Cross Road,
    Ponnagaram Colony,
    Madurai - 625016, Tamil Nadu

        :   97900 94102

    FITA Academy - Pondicherry
    410, Villianur Main Rd,
    Sithananda Nagar, Nellitope,
    Puducherry - 605005
    Near IG Square

        :   93635 21112

  • Trending Courses

    JAVA Training In Chennai Dot Net Training In Chennai Software Testing Training In Chennai Cloud Computing Training In Chennai AngularJS Training in Chennai Big Data Hadoop Training In Chennai Android Training In Chennai iOS Training In Chennai Web Designing Course In Chennai PHP Training In Chennai Digital Marketing Course In Chennai SEO Training In Chennai

    Oracle Training In Chennai Selenium Training In Chennai Data Science Course In Chennai RPA Training In Chennai DevOps Training In Chennai C / C++ Training In Chennai UNIX Training In Chennai Placement Training In Chennai German Classes In Chennai Python Training in Chennai Artificial Intelligence Course in Chennai AWS Training in Chennai Core Java Training in Chennai Javascript Training in ChennaiHibernate Training in ChennaiHTML5 Training in ChennaiPhotoshop Classes in ChennaiMobile Testing Training in ChennaiQTP Training in ChennaiLoadRunner Training in ChennaiDrupal Training in ChennaiManual Testing Training in ChennaiSpring Training in ChennaiStruts Training in ChennaiWordPress Training in ChennaiSAS Training in ChennaiClinical SAS Training in ChennaiBlue Prism Training in ChennaiMachine Learning course in ChennaiMicrosoft Azure Training in ChennaiUiPath Training in ChennaiMicrosoft Dynamics CRM Training in ChennaiUI UX Design course in ChennaiSalesforce Training in ChennaiVMware Training in ChennaiR Training in ChennaiAutomation Anywhere Training in ChennaiTally course in ChennaiReactJS Training in ChennaiCCNA course in ChennaiEthical Hacking course in ChennaiGST Training in ChennaiIELTS Coaching in ChennaiSpoken English Classes in ChennaiSpanish Classes in ChennaiJapanese Classes in ChennaiTOEFL Coaching in ChennaiFrench Classes in ChennaiInformatica Training in ChennaiInformatica MDM Training in ChennaiBig Data Analytics courses in ChennaiHadoop Admin Training in ChennaiBlockchain Training in ChennaiIonic Training in ChennaiIoT Training in ChennaiXamarin Training In ChennaiNode JS Training In ChennaiContent Writing Course in ChennaiAdvanced Excel Training In ChennaiCorporate Training in ChennaiEmbedded Training In ChennaiLinux Training In ChennaiOracle DBA Training In ChennaiPEGA Training In ChennaiPrimavera Training In ChennaiTableau Training In ChennaiSpark Training In ChennaiGraphic Design Courses in ChennaiAppium Training In ChennaiSoft Skills Training In ChennaiJMeter Training In ChennaiPower BI Training In ChennaiSocial Media Marketing Courses In ChennaiTalend Training in ChennaiHR Courses in ChennaiGoogle Cloud Training in ChennaiSQL Training In Chennai CCNP Training in Chennai PMP Training in Chennai OET Coaching Centre in Chennai

  • Are You Located in Any of these Areas

    Adyar, Adambakkam, Anna Salai, Ambattur, Ashok Nagar, Aminjikarai, Anna Nagar, Besant Nagar, Chromepet, Choolaimedu, Guindy, Egmore, K.K. Nagar, Kodambakkam, Koyambedu, Ekkattuthangal, Kilpauk, Meenambakkam, Medavakkam, Nandanam, Nungambakkam, Madipakkam, Teynampet, Nanganallur, Navalur, Mylapore, Pallavaram, Purasaiwakkam, OMR, Porur, Pallikaranai, Poonamallee, Perambur, Saidapet, Siruseri, St.Thomas Mount, Perungudi, T.Nagar, Sholinganallur, Triplicane, Thoraipakkam, Tambaram, Vadapalani, Valasaravakkam, Villivakkam, Thiruvanmiyur, West Mambalam, Velachery and Virugambakkam.

    FITA Velachery or T Nagar or Thoraipakkam OMR or Anna Nagar or Tambaram or Porur branch is just few kilometre away from your location. If you need the best training in Chennai, driving a couple of extra kilometres is worth it!