-4

My python program isnt running. Im sure im missing something but im pretty sure i just indented wrong. Can anyone lend me a hand? thank you!

def main():
    sales = getSales()
    advancedPay = getAdvancedPay()
    commRate = DetermineCommRate(sales)
    pay = (sales * commRate) - advancedPay
    print("The pay is $". format(pay, ",.2f"), sep="")
    
if pay < 0:
    print("The salesperson must reimburse")
    print("the company")

def getSales():
    monthlySales = float(input("Enter the monthly sales: "))
    return monthlySales

def getAdvancedPay():
    print("Enter the amount of advanced pay or ")
    print("Enter 0 if no advanced pay was given. ")
    advancedPay - float(input("Advanced pay: ")
    return advancedPay
    

def DetermineCommRate
    if sales < 10000:
        rate = 0.10
    elif sales >= 10000 and sales <= 14999.99:
        rate = 0.12
    elif sales >= 15000 and sales <= 17999.99:
        rate = 0.14
    elif sales >= 18000 and sales <= 21999.99:
        rate = 0.16
    else:
        rate = 0.18

    return rate

main()

My python program isnt running. Im sure im missing something but im pretty sure i just indented wrong. Can anyone lend me a hand? thank you!

2 Answers2

1

From what I can see, sales is a local variable in the main(), and you are trying to access it in DetermineCommRate, and you have syntax errors in the definition of that function

def DetermineCommRate(sales):

Currently, you are passing sales to it, but not accepting it.

Also, your following line should be indented to run in the main()

if pay < 0:
    print("The salesperson must reimburse")
    print("the company")

And a syntax error in this line too

advancedPay = float(input("Advanced pay: "))
Silencer310
  • 862
  • 2
  • 8
  • 25
0

Thanks for the comments; I deleted the invalid stuff and kept working on the program.

You're missing several syntax errors. You need to close off parentheses in the input of advancedPay, finish the declaration of DetermineCommRate, indent the if pay block, and then reconcile that declaration (number & names of params) with the use (one argument).

You also have a formatting problem with the final printing. Check the examples again and fix the specification to print pay.

def main():
    sales = getSales()
    advancedPay = getAdvancedPay()
    commRate = DetermineCommRate(sales)
    pay = (sales * commRate) - advancedPay
    print("The pay is $ {0:8.2f}". format(pay), sep="")

    if pay < 0:
        print("The salesperson must reimburse")
        print("the company")

def getSales():
    monthlySales = float(input("Enter the monthly sales: "))
    return monthlySales

def getAdvancedPay():
    print("Enter the amount of advanced pay or ")
    print("Enter 0 if no advanced pay was given. ")
    advancedPay = float(input("Advanced pay: "))
    return advancedPay

def DetermineCommRate(sales):
    if sales < 10000:
        rate = 0.10
    elif sales >= 10000 and sales <= 14999.99:
        rate = 0.12
    elif sales >= 15000 and sales <= 17999.99:
        rate = 0.14
    elif sales >= 18000 and sales <= 21999.99:
        rate = 0.16
    else:
        rate = 0.18

    return rate

main()
Prune
  • 76,765
  • 14
  • 60
  • 81