Employees and managers
Mediuminheritancesuperoverriding methods· 20 XP
The payroll team needs yearly pay for two kinds of staff. Everyone gets a base salary plus a bonus; managers also get extra for each person who reports to them.
Write two classes:
Employee(name, salary)with a methodyearly_pay()that returns the salary plus a 5% bonusManager(name, salary, reports)that inherits fromEmployee, wherereportsis a number of people, and whoseyearly_pay()adds1000per report on top of what an employee gets
Return the pay rounded to 2 decimals.
How it's checked
Your code runs, then the check below runs and its printed output is compared with ours.
Employee("Ana", 60000).yearly_pay()returns63000.0, andManager("Ben", 80000, 3).yearly_pay()returns87000.0
Hints, the later questions and the answer come with Pro.
class Employee:
def __init__(self, name, salary):
...
class Manager(Employee):
...