Question

In: Computer Science

Write a function called compute_pay that accepts arguments representing the hourly wage of an employee and the number of hours that employee worked this week.

Python Rephactor


Compute Take Home Pay

Write a function called compute_pay that accepts arguments representing the hourly wage of an employee and the number of hours that employee worked this week. The function should return the take home pay owed to the employee as a floating point value rounded to two decimal places.

The normal work week is 40 hours, and the company pays employees "time and a half" for overtime. So, the total wages is the sum of regular wages and overtime wages. Regular wages are the hours worked (up to 40) times the hourly wage. Overtime wages are any hours over 40 times the hourly wage times 1.5.

The employee's take home pay is the total wages minus taxes and medical costs. Taxes are 20% of the total wages, and medical costs are 10% of the total wages.

Suppose an employee makes $12.25 per hour and has worked 45 hours this week. The take home pay for that employee is 40 hours times 12.25, plus 5 hours times 18.50 (time-and-a-half), minus taxes and medical, for a total of $407.31.

Solutions

Expert Solution

def compute_pay(rate,hours):
wage=rate*min(hours,40)
#overtime rate
orate=rate*1.5
#add overtime amount
if(hours>40):
wage+=(hours-40)*orate
#deduction = 20 + 10 =30%
wage=wage*0.7
return round(wage,2)

======

Output:

======

The function take hourly rate and no. of hours as input.

Intially it calculates wage for regular hours (<=40) and then adds overtime to it by multiplying it with the overtime rate (orate=rate*1.5).

Since deductions made are 20% for tax and 10% for medical total deduction are 30%. So remaining part is 70%.

So 70% of wage is returned by rounding it two decimal places.


Related Solutions

An employee receives an hourly wage rate of $16, with time-and-a-half for all hours worked in excess of 40 during the week.
An employee receives an hourly wage rate of $16, with time-and-a-half for all hours worked in excess of 40 during the week. Payroll data for the current week are as follows: hours worked, 47; federal income tax withheld, $145; social security tax rate, 6.0%; Medicare tax rate, 1.5%; state unemployment compensation tax, 3.4% on the first $7,000; and federal unemployment compensation tax, 0.8% on the first $7,000. What is the net amount to be paid to the employee? Round your...
1. An employee receives an hourly wage rate of $24, with time-and-a-half for all hours worked...
1. An employee receives an hourly wage rate of $24, with time-and-a-half for all hours worked in excess of 40 during the week. Payroll data for the current week are as follows: hours worked, 44; federal income tax withheld, $145; social security tax rate, 6.0%; Medicare tax rate, 1.5%; state unemployment compensation tax, 3.4% on the first $7,000; and federal unemployment compensation tax, 0.8% on the first $7,000. What is the net amount to be paid to the employee? Round...
In a program, write a function that accepts two arguments: a list, and a number n....
In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contains numbers. The function should display all of the numbers in the list that are greater than the number n. The program should ask for a list of numbers from the user as well as a value (a, b, c)--> inputs from user. After that, each number in that list should be compared to that value (a or b or...
Write a function called draw_card. It takes no arguments and returns an integer representing the value...
Write a function called draw_card. It takes no arguments and returns an integer representing the value of a blackjack card drawn from a deck. Get a random integer in the range 1 to 13, inclusive. If the integer is a 1, print "Ace is drawn" and return 1. If the integer is between 2 and 10, call it x, print "<x> is drawn" and return x (print the number, not the string literal "<x>"). If the number is 11, 12,...
Using Python #Write a function called after_second that accepts two #arguments: a target string to search,...
Using Python #Write a function called after_second that accepts two #arguments: a target string to search, and string to search #for. The function should return everything in the first #string *after* the *second* occurrence of the search term. #You can assume there will always be at least two #occurrences of the search term in the first string. # #For example: # after_second("11223344554321", "3") -> 44554321 # #The search term "3" appears at indices 4 and 5. So, this #returns everything...
Write a function that accepts an int array and the array's size as arguments.
Write a function that accepts an int array and the array's size as arguments. The function should create a copy of the array, except that the element values should be reversed int the copy. The function should return a pointer to the new array. Demonstrate the function in a complete program.  
The table to the right lists the average number of hours worked in a week and...
The table to the right lists the average number of hours worked in a week and the average weekly earnings for U.S. production workers from 1967 to 1996. (The World Almanac 1998) 1) Construct a scatter diagram and comment on the relationship, if any, between the variables Weekly Hours and Weekly Earnings. 2) Determine and interpret the correlation for hours worked and earnings. Based upon the value of the correlation, is your answer to the previous question reasonable? 3) Based...
Differences in labor earnings are the result of wage differentials and the number of hours worked....
Differences in labor earnings are the result of wage differentials and the number of hours worked. Explain each of the following reasons for wage differentials: (a) occupational immobility, (b) compensating differentials, (c) cost of acquiring skills and (d) geographical immobility.
Martin Jackson receives an hourly wage rate of $17, with time-and-a-half pay for all hours worked...
Martin Jackson receives an hourly wage rate of $17, with time-and-a-half pay for all hours worked in excess of 40 hours during a week. Payroll data for the current week are as follows: hours worked, 48; federal income tax withheld, $163; social security tax rate, 6.0%; and Medicare tax rate, 1.5%. What is the net amount to be paid to Jackson, rounded to the nearest cent?
Write a Python function that accepts three arguments: an array, the size of the array, and...
Write a Python function that accepts three arguments: an array, the size of the array, and a number n. Assume that array contains integers. The function should display all integers in the array that are greater than the number n. Test your function.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT