我是python编程的初学者。正在尝试使用numpy软件包来计算杂志发行的总利润。不确定我在哪里犯错,结果放在方括号中。
建议我的错误所在以及如何调试此错误以解决问题。并且我对命令的用法正确吗?
distr = np.array([[0.315, 0.226, 0.289, 0.087, 0.083],
[560, 530, 389, 202, 278],
[533, 486, 386, 234, 263]])
order_1 = np.array([[430,430,430,430,430],
[380,380,380,380,380]])
probs = np.array([0.315, 0.226, 0.289, 0.087, 0.083])
paper1 = np.array([560, 530, 389, 202, 278])
paper2 = np.array([533, 486, 386, 234, 263])
order1 = np.array([430,380])
price = np.array([1.0,1.15])
price1 = np.array([1.0])
cost = np.array([0.6,0.8])
expected_soldqty1 =(np.minimum(order.reshape((2,1)), distr[1:]))
print ('Expected SOld Qty:' + str(expected_soldqty1))
selling_price = np.dot((expected_soldqty),(price.reshape(2,1)))
print ('Selling_price :' + str(selling_price))
cost_price= np.sum(np.dot(cost.reshape((2,1)),order_1[0:1]))
print ('Cost Price :' + str(cost_price))
profit = np.subtract(selling_price,cost_price)
print ('Expected total Profit :' + str(profit))
Result:
Expected SOld Qty:[[430. 430. 389. 202. 278.]
[380. 380. 380. 234. 263.]]
Selling_price :[3611.55]
Cost Price :3010.0
Expected total Profit :[601.55]