Anonymous
Anonymous asked in Computers & InternetProgramming & Design · 2 weeks ago

what is wrong with my python code?

def computepay(h,r):

    if h <= 40:

        return (h*r)

    elif hrs > 40:

        return ((40*r)+((h-40)*(r*1.5)

r = float(raw_input("Enter Hourly rate:"))

h = float(raw_input("Enter Hours:"))

p = def computepay(h,r):

print (p)

1 Answer

Relevance
  • EddieJ
    Lv 7
    2 weeks ago

     elif hrs > 40:

    should just be

    else:

    You know it's greater than 40 because the <if> already tested for <=.

    However, you also used "hrs" when the parameter is "h".

    Meanwhile, you don't even need the <else> because if the <if> was true, you'd have already returned.  So you just need the 2nd return to be unindented.

    But the return has unbalanced parens, and more than you need.

    return (40*r)+(h-40)*(r*1.5)

    or

    return 40*r + (h-40) * r * 1.5

    p = def computepay(h,r):

    should be

    p = computepay (h,r)

    our you could delete that statement and have

    print (computepay (h,r))

Still have questions? Get your answers by asking now.