Return to: Education News

Inheritance in Python - tccicomputercoaching.com



Definition:
Inheritance is the mechanism to build a new class from old class. So, new class can access the data property of old class.
Old class is called parent class and new class is called child class.
What can child class can do?
-Child calls can reuse data or function of parent class.
-Child class can redefine function of parent class.
-Child class can add own data also.
Programming Structure of Inheritance:
class parent:
.....data
.....def fun1(self):
..........
class child(parent):
....data declaration
....def fun2(self):
........statement
>>>obj=child()
obj.fun1()
obj.fun2()
Here, obj is instance created for the class child. We can call fun of parent and child both using this instance of child class.


There are types of inheritance depending number of parent and child.
1. Single inheritance
2. Multilevel inheritance
3. Multiple inheritance
4. Hierarchy inheritance
5. Hybrid inheritance
To learn more about inheritance, Python, Programming Language, TCCI.
Call us @ 9825618292
Visit us @ http://tccicomputercoaching. ...

News Release: Inheritance in Python - tccicomputercoaching.com
Submitted on: July 12, 2019 11:38:47 AM
Submitted by: Rosario Riley
On behalf of: www.tccicomputercoaching.com
advertisement