Hello I am trying to create a program where you input how many hours you worked and the rate per hour. Every hour over 40 is counted as over time (x1.5).
I am getting a nameError on line 11. ( ganancias = (horas * tarifa)
NameError: name 'horas' is not defined)
I dont understand why since I defined "horas" in the second line. Thanks for your time!
def calculo_salario() :
horas = float(input("input salario: "))
tarifa = float(input("input tarifa: "))
def sums(a,b):
sum = a + b
return sum
calculo_salario()
ganancias = (horas * tarifa)
preOt = (40 * tarifa)
if horas > 40 :
overtimeHr = horas - 40
overtimeAm = (overtimeHr * tarifa) * 1.5
gananciasOt = sums(overtimeAm, preOt)
print(gananciasOt)
else :
print(ganancias)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…