Research breakthrough possible @S-Logix pro@slogix.in

Office Address

  • 2nd Floor, #7a, High School Road, Secretariat Colony Ambattur, Chennai-600053 (Landmark: SRM School) Tamil Nadu, India
  • 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

Sample 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
implement inheritance in python