Foundations of Python

You are currently auditing this course.
37 / 134

Python - Create Payment Calculator Function

Create a function to calculate the payment to be made based on the hours and rate provided.

INSTRUCTIONS
  • Create a function pay_calculator which will calculate the payment to be made to an employee
  • The function will take 2 arguments; hours, and rate, in that order
  • If the hours are less than or equal to 40, then the payment will be a product of the hours and rate
  • If the hours are greater than 40, then till the 40th hour the payment will be calculated as a product of the hours and rate variables. Beyond the 40th hour, the rate will be 1.5 times that of the original rate variable
  • The function will finally compute the total pay, save it in a variable named total_pay and will return the same
  • Finally, test the function with the following values: hours = 45, and rate = 10
  • The output for the above values should be 475.0

Loading comments...