On Sun, May 01, 2016 at 5:34 PM, Olaoluwa Thomas < thomasolaol...@gmail.com
[thomasolaol...@gmail.com] > wrote:
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*
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Hi, The parameters hours and rate are required when calling the method
computepay ex: computepay(8, 200), so basically computepay() by itself will
throw an error .... Also, as a suggestion if you're gonna get hours and
rate via user input perhaps they can be removed from the method definition?
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor