Answers for "calculate gross pay in python"

0

calculate gross pay in python

def weeklyPay(hours, wage):
    if hours > 40:
        return 40 * wage + (hours - 40) * wage * 1.5
    else:
        return hours * wage
 
def getFloat(prompt):
    while True:
        try:
            return float(input(prompt))
        except ValueError:
            print("This is an invalid value. Try again. ")
 
hours = getFloat("How many hours did you work? ")
wage = getFloat("What was your hourly rate? ")
 
pay = weeklyPay(hours, wage)
 
print(f"Total pay: ${pay:.2f} ")
Posted by: Guest on September-25-2020

Code answers related to "calculate gross pay in python"

Python Answers by Framework

Browse Popular Code Answers by Language