我正在尝试编写一个程序来计算经销商利润(获得25%的销售利润)和新车销售(获得35%的销售利润)。它应计算两者的佣金,然后加在一起以获得总佣金。我的程序正在运行所需的输出,但当它达到总佣金时,我收到下面列出的错误:
Enter pre-owned sales profit: 3600
Enter new sales profit: 18000
Pre_owned_sales * 0.25/100: $900
Commission new sales * 0.35/100: $6300
Traceback (most recent call last):
File "C:/Users/Darlene/Desktop/CAR_SALES_PROFIT04232016.py", line 15, in <module>
main()
File "C:/Users/Darlene/Desktop/CAR_SALES_PROFIT04232016.py", line 6, in main
total = float(input('Total Commission:$', commission_preowned_sales,'+',commission_new_sales))
TypeError: input expected at most 1 arguments, got 4
有人可以告诉我在下面的程序中我做错了什么吗?:
def main():
pre_owned_vehicles = float(input("Enter pre-owned sales profit: "))
new_vehicles = float(input("Enter new sales profit: "))
commission_preowned_sales = float(input("Pre_owned_sales *0.25/100: $"))
commission_new_sales = float(input("Commission new sales *0.35/100: $"))
total = float(input('Total Commission:$', commission_preowned_sales,'+',commission_new_sales))
print('Pre-owned_sales_profit is $',format(pre-owned_sales_profit,'.2f'))
print('New_sales_profit_is $',format(new_sales,'.2f'))
print('Pre-owned_commission_is $',format(Pre-owned_commission,'.2f'))
print('New_sales_commission_is $',format(new_sales_commission,'.2f'))
print(profit + commission,'$',format(total_pay,'.2f'),sep='')
main()
答案 0 :(得分:0)
如果commission_preowned_sales
和commission_new_sales
是total
所需的唯一变量,则total
不需要用户提供额外的输入,在这种情况下input
正在不必要地使用。出现错误是因为input
函数只接受一个参数(一个string
在控制台中打印请求输入)。考虑更新为total = commission_preowned_sales + commission_new_sales
。 float
在技术上是可选的,因为这些变量已经转换为float。