[Tutor] Issues converting a script to a functioin (or something)
Olaoluwa Thomas
thomasolaoluwa at gmail.com
Sun May 1 07:55:27 EDT 2016
The novice Python programmer is back.
I'm trying to incorporate a function and its call in the GrossPay.py script
that Alan solved for me.
It computes total pay based on two inputs, no. of hours and hourly rate.
There's a computation for overtime payments in the if statement.
Something seems to be broken.
Here's the code:
def computepay(hours, rate):
hours = float(raw_input ('How many hours do you work?\n'))
rate = float(raw_input ('What is your hourly rate?\n'))
if hours > 40:
gross = ((hours - 40) * (rate * 1.5)) + (40 * rate)
elif hours >= 0 and hours <= 40:
gross = hours * rate
print "Your Gross pay is "+str(round(gross, 4))
computepay()
What am I doing wrong?
*Warm regards,*
*Olaoluwa O. Thomas,*
*+2347068392705*
More information about the Tutor
mailing list