We will create a class named student which is inherited by two classes Bsc and Ba. Then we have used the get method to get input of information from the user. And then print the details using the print method.

Classes and members:
- Class - student
- Method - getStudentInfo() : Gets input from user for variables of the class.
- Method - putStudent() : prints student information.
- Variable - rollNo : stores student's roll number.
- Variable - name : stores student's name.
- Class - Bsc
- Method - getBsc() : Gets input from user for variables of the class.
- Method - putBsc() : prints Bsc information and calls putStudent.
- Variable - p : stores student's physics marks.
- Variable - c : stores student's chemistry marks.
- Variable - m : stores student's maths marks.
- Class Ba
- Method - getBa() : Gets input from user for variables of the class.
- Method - putBa() : prints Ba information and calls putStudent.
- Variable - h : stores student's history marks.
- Variable - g : stores student's geography marks.
- Variable - e : stores student's economics marks.
Python program to illustrate Hierarchical Inheritance
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer