【发布时间】:2014-10-27 04:19:19
【问题描述】:
def main():
bonus()
def bonus():
#Dollars from sales are input, then time worked,
#then the salary and possible bonus is added
#to the calculated commission based on the earned commission rate
monthlySales=int(input('How much money did your employee make in sales?',))
if monthlySales<10000:
commRate=0
elif monthlySales>=10000 and monthlySales<100000:
commRate=0.02
elif monthlySales>=100001 and monthlySales<500000:
commRate=0.15 and monthlyBonus=1000
elif monthlySales>=500001 and monthlySales<1000000:
commRate=0.28 and monthlyBonus=5000
elif monthlySales>1000000:
commRate=0.35 and monthlyBonus=100000
yearsWorked=int(input('How many years has your employee worked here? Round down to the nearest year.',))
if yearsWorked>=5 and monthlySales>=100000:
extraBonus+1000
elif yearsWorked<1:
monthsWorked=int(input('How many full months has your employee worked here?',))
if monthsWorked<3:
print('Your employee has not worked here long enough to qualify for a bonus.')
main()
我想做的是制定一个计划,在该计划中,预先确定的佣金率取决于员工在该计划中的销售额。
我收到“无法分配给操作员”错误
commRate=0.35 and monthlyBonus=100000
,这告诉我在 if 嵌套中直接分配数值的其余变量将得到相同的错误。
我做错了什么,在这里?
【问题讨论】:
-
分成两行删除
and或使用分号; -
使用元组赋值
a, b = 1, 2导致a == 1和b == 2