How do I write a function in Python which takes as input the basic salary(basic) and number of hours of overtime worked(overtime). The function should return as output a matrix with five rows and six columns. All entries of the matrix should be rounded to the nearest whole number. Each row corresponds to an employee, and
• the first column should contain the employee number,
• the second column contains their basic salary,
• the third column contains their deductions for November,
• the fourth column contains the number of hours overtime worked,
• the fifth column contains their overtime pay, and
• the sixth column contains their net salary for November.
The value of the ratio of deduction(written as deduction in code) and overtime rate(otrate) which is money earned per hour of overtime work varies on the value of the basic salary. Here is a basic code that I constructed to convey the information:
if (basic < 3000):
deduction = 0.15
otrate = 20
netsalary = basic * (1-deduction) + (overtime * otrate)
elif (basic < 5000):
deduction = 0.21
otrate = 40
netsalary = basic * (1-deduction) + (overtime * otrate)
elif (basic < 8000):
deduction = 0.27
otrate = 60
netsalary = basic * (1-deduction) + (overtime * otrate)
else:
deduction = 0.33
otrate = 80
netsalary = basic * (1-deduction) + (overtime * otrate)
(fourth column) Deduction amount = Basic salary * ratio of deduction
(fifth column) Overtime pay = Hours worked overtime * rate of overtime pay
Net salary = basic salary * (1 - ratio of deduction) + hours worked overtime * overtime rate
Aucun commentaire:
Enregistrer un commentaire