[Python] Why Function returning None in Python Output

Discussão em 'Python' iniciado por Stack, Julho 17, 2025.

  1. Stack

    Stack Membro Participativo

    I want to know why the following two codes are returning None in Python output? Can somebody help me writing both codes correctly separately and tell me what's causing it to return None and explain please? I need the following output: Pay 498.75

    # 1st Code - Returning None
    def computepay(int1,int2):
    try:
    h = float(int1)
    r = float(int2)
    except:
    print ("Error, please enter a numeric input")
    quit()
    if h >= 40:
    pay1 = 40 * r + (h - 40) * r * 1.5

    #print(pay1)
    else:
    pay2 = h * r
    #print( pay2)
    p = computepay(45,10)
    print("Pay",p)


    # 2nd Code - Returning None
    def computepay(int1,int2):
    try:
    h = float(int1)
    r = float(int2)
    except:
    print ("Error, please enter a numeric input")
    quit()
    if h >= 40:
    pay1 = 40 * r + (h - 40) * r * 1.5

    print(pay1)
    else:
    pay2 = h * r
    print( pay2)
    print("Pay",computepay(45,10.5))
    #print("Pay",p)

    Continue reading...

Compartilhe esta Página