Question
Python Help, please help with exercise 7 Exercise 5: exercise 6: Now let's help payroll do something with the output of our function. They have
Python Help, please help with exercise 7
Exercise 5:
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 7! Thank you.
In [14]: # Write your code for Exercise 5 here def findPay (hours_worked, rate_of_pay): if hours_worked 40: overtime-hours_worked-40 hours-40 else: hours-hours worked pay_for_week-(hours *rate_of_pay)+(overtime * rate_of_pay * 1.5) return pay for_week In [15]: | # 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, 475.0 rate_of_pay)) In [16]: def findPay (hours_worked, rate of_pay): if hours worked>40: overtime-hours worked-40 hours-40 else: hours-hours worked pay_for_week-(hoursrate_of_pay)+(overtimerate_of_pay 1.5) return pay_for_week hoursworked = 45 rate of_pay-10 pay_for_week- findPay (hours_worked, rate_of_pay) if pay_for_week 375: - %f %f Pay 475.000000 by direct deposit print('Pay direct by by mailed deposit' %(pay-for-week)) else: print( 'Pay check, %(pay-for-week))
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started