Manager Pay
Python
30 pts
Manager Pay
Create a class Employee with __init__(self, name, salary) and two methods:
monthly_pay()returns the salary.describe()returnsname earns X Nakfa, where X comes fromself.monthly_pay().
Create a child class Manager(Employee) with an extra bonus. It overrides monthly_pay() to return the parent’s pay plus the bonus, using super().monthly_pay(). Do not write describe() in Manager.
Expected output:
Selam earns 8000 Nakfa Merhawi earns 15000 Nakfa
Checklist
- Define a class
Employeewithmonthly_pay(), which returns the salary, anddescribe(), which returnsname earns X Nakfa. - Create a child class
Managerthat stores the salary (through the parent) and abonus. - Override
monthly_pay()inManagerto add the bonus to the parent's pay, and do not writedescribe()inManager. - Run the code at the bottom.
🔑 Solution
If you view the solution before passing, you earn half points for this exercise. You still need to type it and press Check to finish.
How it works, step by step
Point at a step to highlight its lines. Type the solution yourself and press Check answer to finish.
