首页 > 解决方案 > 为推销员做一个 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)

收到错误图片

标签: python

解决方案


25 / sales = commission此行引发错误。我认为应该是comission = 25 / sales。您尝试将 的值分配给其不起作用comission的结果。25 / sales


推荐阅读