Question: Python Help- I have done exercise 5, although I do not know why I am getting None in my output. Next, I have to modify

Python Help- I have done exercise 5, although I do not know why I am getting "None" in my output.

Python Help- I have done exercise 5, although I do not know

Next, I have to modify this. I need help with that.

Exercise 6

Now let's help payroll do something with the output of our function. They have a rule that people who get paid at least $375 are paid by direct deposit to their bank account; everyone else (who is paid less than $375) gets paid by check in the mail.

Write a simple program (using conditionals) that calls the compute_pay function, stores the result in a variable pay_for_week, and prints "Paying x by direct deposit" if pay_for_week is at least 375, and "Paying pay_for_week by mailed check if x is less than 375.

Here are some test cases:

  • If the number of hours worked is 45, and the rate of pay is 10, you should print "Paying 475 by direct deposit"
  • If the number of hours worked is 35, and the rate of pay is 10, you should print "Paying 350 by mailed check"
  • If the number of hours worked is 63, and the rate of pay is 10, you should print "Paying 745 by direct deposit"

Exercise 7

Now imagine that we have a list of 5 employees who have each worked 45, 15, 63, 23, and 39 hours. We'll fix rate_of_pay at 10. Payroll wants to mail checks for each of these employees. Use a definite loop (for loop) to loop through the list of employee hours and print the appropriate pay statement.

Your output should look something like:

Paying 475.0 by direct deposit Paying 150.0 by mailed check Paying 745.0 by direct deposit Paying 230.0 by mailed check Paying 390.0 by direct deposit

# Write your code for Exercise 7 here

# Set rate of pay rate_of_pay = 10

# Write the for loop here. Make it iterate over this list: [45, 15, 63, 23, 39]

Please show and explain the code that will complete exercise 6 and 7! Thank you.

Exercise 5 Now let's modify our program from Exercise 3 even more! Let's imagine that we want to pass on our pay computation to another step for the payroll ople who want to do various things with the pay computations for each employee. Let's make life easier for payroll. Rewrite your program above o a function that takes two parameters (hours worked and rate_of_pay), and returns pay_for_week. In [1]: # Write your code for Exercise 5 here def findPay (hours_worked, rate_of_pay): overtime 0 hours = 0 if hours_worked 40: overtimehours worked 40 hours 40 else: hours -hours worked payfor week (hours * rateof_pay) + (overtime *rate of pay *1.5) print(pay_for_week) In [5]: # Test your function here by calling it. You should see 475 as the output. hours-worked 45 rate of pay - 10 print(findPay (hours_worked, rate_of_pay)) 475.0 None

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!