Basic computer course, C programming language, Education, Engineering Course, Engineering Courses, Maths Coaching, online computer coaching, PGDCA course coaching, programming course, school computer coaching, training, Uncategorized, Web Design course

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.

python inheritance at tcci

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.com/

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s