#5, First Floor, 4th Street , Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 pro@slogix.in

Office Address

  • #5, First Floor, 4th Street Dr. Subbarayan Nagar Kodambakkam, Chennai-600 024 Landmark : Samiyar Madam
  • pro@slogix.in
  • +91- 81240 01111

Social List

How to implement inheritance in python?
Description

To implement inheritance in python3.

Process
Inheritance:

   Like other object oriented language python also does inheritance.

   To create new class from base class stats and behaviour.

   Base class act as like parent class.

   Inherited class act like child class.

   It gives the the oops concept of re usability.

Syntax(simple inheritance):

class BaseClass:

Body of base class

class DerivedClass(BaseClass):

Body of derived class

Sapmle Code

#Parent class
class car:

#parent class method
def models(self):
print(‘Four wheel’)

#child class
class bike(car):

#child class method
def model(self):
print(‘Two wheeler’)

#object creation for child class
a=bike()

#call parent class method using child class object
a.models()
a.model()

Screenshots