为了账号安全,请及时绑定邮箱和手机立即绑定

为一名推销员开发 Python 项目。出现“无法分配给操作员”错误

为一名推销员开发 Python 项目。出现“无法分配给操作员”错误

叮当猫咪 2023-12-26 15:20:50
我正在为一名推销员开发一个 Python 项目。该项目根据每周的工作时间和每周销售佣金的百分比计算工资,并将它们加在一起得到销售员的每周总工资。我遇到的问题是将销售额除以他们从每次销售中获得的百分比。错误是“无法分配给操作员”#Prompt user for the number of hours worked that week hours_worked = int(input("How many hours did you work this week? \n"))#Define hourly wageper_hour = 30#Multiply the hourly wage and hours worked that weektotal_hours_pay = hours_worked * per_hour#Prompt user for the number of sales made that weeksales_made = int(input("How many sales did you make this week? \n"))#Amount of each salesales = 250#Determine commission of each sale25 / sales = commission#Multiply the commission times the amount of sales made to retrieve amount of total commission paytotal_sales_pay = sales_made * commission#Add total commission pay from sales with the total hours pay to get the weekly totaltotal_week_pay = total_sales_pay + total_hours_payprint(total_week_pay)
查看完整描述

2 回答

?
largeQ

TA贡献2039条经验 获得超7个赞

你写了:

25 / sales = commission

但是当给变量赋值时,需要将变量放在语句的开头。

尝试

commission = 25 / sales


查看完整回答
反对 回复 2023-12-26
?
阿波罗的战车

TA贡献1862条经验 获得超6个赞

25 / sales = commission这一行抛出错误。我想应该是的comission = 25 / sales。你尝试将 的值赋值comission给其结果25 / sales不起作用。



查看完整回答
反对 回复 2023-12-26
  • 2 回答
  • 0 关注
  • 113 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信