# pay_calc.py # This program takes input of hours worked and hourly rate and calculates # the total wages for the week. # by: Scott Gordon def main(): print("***** Welcome to the Pay Calculator *****\n") hours_worked = float(input("Enter the amount of hours worked: ")) hourly_rate = float(input("Enter the hourly rate: ")) def pay_calculator(hours, pay_rate): """Calculates total pay based on the amount of hours worked and pay rate. Time-and-a-half is calculated for any hours worked over 40.""" if (hours > 0) and (pay_rate > 0): if hours <= 40: pay = hours * pay_rate return f"\nYour pay is ${pay:.2f}" else: pay = (40 * pay_rate) + ((pay_rate * 1.5) * (hours - 40)) return f"\nYour pay with overtime is ${pay:.2f}" else: return "\nYou must enter a number greater than 0 for hours and pay." print(pay_calculator(hours_worked, hourly_rate)) if __name__ == '__main__': main()
Фото Шарон МакКучеон на Бессмысленно
Оригинал: “https://dev.to/sagordondev/pay-calculator-1ddo”