Software development is a team effort. Several programmers will work as a team to develop software. When a programmer develops a class, he will use its features by creating an instance to it. When another programmer wants to create another class which is similar to the class already created, then he need not create the class from the scratch. He can simply use the features of the existing class in creating his own class.
A programmer in the software development is creating Teacher class with setter() and getter() methods. Then he saved this code in a file 'teacher.py'.
When the programmer wants to use this Teacher class that is available in teacher.py file, he can simply import this class into his program and use it as shown below:
Now, another programmer in the same team wants to create a Student class. He is planning the Student class without considering the Teacher class as shown below
Now, the second programmer who created this Student class and saved it as student.py can use it whenever he needs.
If we compare the Teacher class and the Student classes, we can understand that 75% of the code is same in both the classes. That means most of the code being planned by the second programmer in his Student class is already available in the Teacher class. Then why doesn't he use it for his advantage? Our idea is this: instead of creating a new class altogether, he can reuse the code which is already available.
This means the Student class is derived from Teacher class. Once we write like this, all the members of Teacher class are available to the Student class. Hence we can use them without rewriting them in the Student class.