python - 为推销员做一个 Python 项目。出现“无法分配给操作员”错误
问题描述
我正在为推销员做一个 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 wage
per_hour = 30
#Multiply the hourly wage and hours worked that week
total_hours_pay = hours_worked * per_hour
#Prompt user for the number of sales made that week
sales_made = int(input("How many sales did you make this week? \n"))
#Amount of each sale
sales = 250
#Determine commission of each sale
25 / sales = commission
#Multiply the commission times the amount of sales made to retrieve amount of total commission pay
total_sales_pay = sales_made * commission
#Add total commission pay from sales with the total hours pay to get the weekly total
total_week_pay = total_sales_pay + total_hours_pay
print(total_week_pay)
解决方案
25 / sales = commission
此行引发错误。我认为应该是comission = 25 / sales
。您尝试将 的值分配给其不起作用comission
的结果。25 / sales
推荐阅读
- windows - AutoHotKey :: 功能键无法正常工作
- python - 如何在 matplotlib 中为交互式绘图的 onclick(event) 函数创建类?
- java - scala-maven-plugin 在提到时无法找到源目录
- java - 使用 Safari 浏览器使用 Selenium 进行自动化测试
- python - 将 Python 类实例保存为 Maya 场景对象
- javascript - 如何使用输入验证 ROC 和 UENO 公司类型?(新加坡)
- shell - 如何使用 sed 替换数字?
- python - Matplotlib 热图 Y 轴
- php - WooCommerce 以某种方式阻止 AJAX 请求返回?
- reactjs - 错误:EPERM:不允许操作,mkdir