Alina - 10 months ago 44

Python Question

I keep getting the following error and my program will not run. I need to make sure my program is modular and have the

`if-then`

`BASE_HOURS = 40`

OT_MULTIPLIER = 1.5

def main():

hours = input("Enter the number of hours worked: ")

payRate = input("Enter the hourly pay rate: ")

calcPayWithOT(hours,payRate)

def calcPayWithOT(hours,payRate):

if hours <= BASE_HOURS:

theGrossPayNoOT = hours * payRate

print("The gross pay is $ ", theGrossPayNoOT)

if hours > BASE_HOURS:

theGrossPayOT = (hours - BASE_HOURS) * OT_MULTIPLIER + (hours * payRate)

print("The gross pay is $ ", theGrossPayOT)

main()

Answer

You should convert the `hours`

and `payRate`

into integers or floats like so:

```
hours = int(input("Enter the number of hours worked: "))
payRate = int(input("Enter the hourly pay rate: "))
```

or

```
hours = float(input("Enter the number of hours worked: "))
payRate = float(input("Enter the hourly pay rate: "))
```

Depending if you want to include only natural numbers or ones with figures after the decimal `.`

Source (Stackoverflow)