0% found this document useful (0 votes)
13 views2 pages

Inheritance Practice Questions

The document outlines various programming tasks involving class inheritance in Python. It includes creating classes for calculating area and perimeter of rectangles, storing athlete details for the Olympics, and managing employee salary details with bonuses. Additionally, it specifies the creation of different employee roles with specific pay structures and the generation of pay slips.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views2 pages

Inheritance Practice Questions

The document outlines various programming tasks involving class inheritance in Python. It includes creating classes for calculating area and perimeter of rectangles, storing athlete details for the Olympics, and managing employee salary details with bonuses. Additionally, it specifies the creation of different employee roles with specific pay structures and the generation of pay slips.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Inheritance Practice Questions

1) Class Area

Member function: calc_area () ---- length * breadth

Class Perimeter

Member function: calc_perm () ---- 2(length + breadth)

Class Rectangle which is inherited from the classes Area and Perimeter.

Get values of two private variables length and breadth from class Rectangle.

Calculate the area and perimeter of a rectangle in Rectangle class.

2) Implement the following scenario in Python

3) Write a python program using classes and objects to store the details of an athlete participating in
Olympics. The details to be stored include athlete id, Athlete name, Country, Event ,No of Gold
medals , no of silver medals and no: of bronze won in the events. Create a member function for
calculating the number of points scored in the event by using the medal weightage.( gold 10,silver 5
and bronze 2)

e.g. If an athlete has Gold -2,silver 2 and bronze 5

Then points scored are 2*10 + 2* 5+ 5 *2=40 points.

4) Create a class employee with one member function to get the employee id. Create class salary
which is inherited from class employee with a member function to get the salary details such as HRA,
DA, AGP. Create another class Bonus with one member function to get the bonus amount. Create
a class GROSS SALARY which is inherited from the classes salary and Bonus with a member
function to Calculate the total salary earned by the employee.

5)

Create Employee class with Emp_name, Emp_id, Address, Mail_id, Mobile_no as members.

Inherit the classes, Programmer, Assistant Professor, Associate Professor and Professor from
employee class.

Add Basic Pay (BP) as the member of all the inherited classes with 97% of BP as DA, 10 % of BP as
HRA, 12% of BP as PF, 0.1% of BP for staff club fund.

BP for Assistant professor: 10000

BP for Programmer: 7500

BP for Associate professor: 20000

BP for Professor: 50000

Generate pay slips for the employees with their net salary.

You might also like