Question
For Python 3 Add functions and include lists. Write a function called get_input() that takes no arguments and returns the name, hours worked, and hourly
For Python 3
Add functions and include lists.
Write a function called get_input() that takes no arguments and returns the name, hours worked, and hourly rate for one employee. The body of the function will include the prompts and store the user input.
Write a function called calc_pay(hours, rate) that takes two arguments and returns the amount the employee gets paid for the week. The body will include the calculation.
Use a list to store the paycheck values for the employees entered. Iterate through the list to calculate the total and average of all employees entered
to the following code:
employ = int(input("How many employees do you want to enter?")) print(" ") tot = 0 for i in range(employ): name = input("Enter a name: ") hours = float(input("Enter hours worked:")) rate = float(input("Enter hourly rate:")) pay = 0 if hours > 40: pay = (40 * rate) + ((hours -40) * 1.5 * rate) else: pay = hours * rate tot += pay print("{} should be paid ${:,.2f}".format(name, pay)) print(" ") print("The total amount to be paid is ${:,.2f}".format(tot)) print("The average employee is paid ${:,.2f}".format(tot/employ))
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