{"id":3832,"date":"2022-12-05T06:32:19","date_gmt":"2022-12-05T06:32:19","guid":{"rendered":"https:\/\/gyanipandit.com\/programming\/?p=3832"},"modified":"2022-12-05T06:32:21","modified_gmt":"2022-12-05T06:32:21","slug":"types-of-inheritance-in-python","status":"publish","type":"post","link":"https:\/\/gyanipandit.com\/programming\/types-of-inheritance-in-python\/","title":{"rendered":"Types of inheritance in Python"},"content":{"rendered":"<p style=\"text-align: center;\">Types of inheritance in Python<\/p>\n<p>Now, that we are quite familiar with the terminologies like Parent class, and child class, now we are going to have a look at some of the different types of inheritance, and before that, we are simply going to understand how we can use inheritance in our programs.<\/p>\n<p>First of all, Let\u2019s have a look at a very simple program, which demonstrates to us how we can use inheritance in our program. The example is very dummy, but it can make things easy to understand for us.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3833 size-full\" src=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/11\/TYPES-OF-INHERITANCE.jpg\" alt=\"\" width=\"664\" height=\"224\" srcset=\"https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/11\/TYPES-OF-INHERITANCE.jpg 664w, https:\/\/gyanipandit.com\/programming\/wp-content\/uploads\/2022\/11\/TYPES-OF-INHERITANCE-300x101.jpg 300w\" sizes=\"auto, (max-width: 664px) 100vw, 664px\" \/><\/p>\n<h2 style=\"text-align: center;\">Types of inheritance in Python<\/h2>\n<p>As you can see in the above program, there is a class ChildClass, which inherits from the class ParentClass. Notice the syntax of how we are implementing the inheritance. While we are defining the sub-class, we are writing the parent class in the brackets.<\/p>\n<p>Here, due to the inheritance, the ChildClass object has access to the ParentClass method, as you can see in the example, which means that we can access that method with the child class object, without any modifications, which leads to code reusability. Do not worry about the syntax, since you would get used to it, once you get using it.<\/p>\n<p>Now, that we have understood how we are implementing inheritance in our programs, now, Let\u2019s have a look at some of the different types of inheritance here. Have a look at the list of different types of inheritance, and we are going to discuss some of the types here &#8211;<\/p>\n<ul>\n<li>Single Inheritance.<\/li>\n<li>Multilevel Inheritance.<\/li>\n<li>Multiple Inheritance.<\/li>\n<li>Hierarchical Inheritance.<\/li>\n<li>Hybrid Inheritance.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Types of inheritance in Python Now, that we are quite familiar with the terminologies like Parent class, and child class, now we are going to have a look at some of the different types of inheritance, and before that, we are simply going to understand how we can use inheritance in our programs. First of [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[26,27],"class_list":{"0":"post-3832","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-python-tutorial","7":"tag-python","8":"tag-python-tutorial"},"_links":{"self":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/comments?post=3832"}],"version-history":[{"count":2,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3832\/revisions"}],"predecessor-version":[{"id":4229,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/posts\/3832\/revisions\/4229"}],"wp:attachment":[{"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/media?parent=3832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/categories?post=3832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gyanipandit.com\/programming\/wp-json\/wp\/v2\/tags?post=3832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}