无法分配给操作员 - Python(加班时间)



所以我正在尝试学习Python,并且正在为这个问题而苦苦挣扎。它要求创建一个程序,您可以在其中输入小时数和小时费率。每工作超过40小时,小时费率将增加1.5。我已经搜索了错误(无法分配给运算符(,但他们说的是我无法为表达式赋值。

horas = float(input("entra las horas trabajadasn"))
porHora = float(input("entra cantidad por horan"))

overTime = 40.0                     #defining
otMult = 1.5
ganancias = (horas * porHora)
if horas > overTime :
    horas - overTime = overtimeHr
    (overtimeAm * porHora) * otMult = overtimeAm
    overtimeAm + ganancias = gananciasOt
    print(gananciasOt)
else :
    print(ganancias)

值(在Ruby和Python中(应该是variable = new_value_expression,而不是new_value_expression = variable。您的所有作业都将被撤消。 horas - overTime不是一个变量,而是一个表达式,因此是错误。代替horas - overTime = overTimeHr,写overTimeHr = horas - overTime(等等(

这是我

的最终代码,感谢我的男孩Amadan ^^

horas = float(input("entra las horas trabajadasn"))
porHora = float(input("entra cantidad por horan"))
                   #defining
ganancias = (horas * porHora)
preOt = (40 * porHora)
if horas > 40 :
    overtimeHr = horas - 40
    overtimeAm = (overtimeHr * porHora) * 1.5
    gananciasOt = overtimeAm + preOt
    print(gananciasOt)
else :
    print(ganancias)

最新更新