题在下面,求帮助
某工厂生产三种产品,每件产品的原料费,工资支付,管理费如表1所示,每个季度生产每种产品的数量如表2所示。
import numpy as np
amt=np.array([[0.6,1.8,0.9],[1.8,2.4,1.5],[0.6,1.2,0.9]])
num=np.array([[4000,4500,4500,4000],[2000,2600,2400,2200],[5800,6200,6000,5000]])
amt1=amt.sum(axis=0)
num1=num.sum(axis=1)
##1
print('四个季度ABC成本总和为:',np.dot(amt1,num1))
num2=num[:,0]
##2
print('第一季度ABC总成本为:',np.dot(amt1,num2))
##3
amtnum=np.dot(amt,num)
print(amtnum)
np.savetxt("cost_product.csv", amtnum,"%.1f", delimiter=",")
import numpy as np
# 创建一个数组来存储每个产品的成本信息
costs = np.array([[0.6, 1.8, 0.6], # 产品 A
[1.8, 2.4, 1.2], # 产品 B
[0.9, 1.5, 0.9]]) # 产品 C
# 创建一个数组来存储每个季度生产的每种产品的数量
production = np.array([[4000, 4500, 4500, 4000], # 产品 A
[2000, 2600, 2400, 2200], # 产品 B
[5800, 6200, 6000, 5000]]) # 产品 C
# 计算总成本
total_cost = np.sum(costs * production)
print(total_cost)
#计算第一季度的总成本
q1_cost = np.sum(costs * production[:, 0])
print(q1_cost)
# 计算每个季度的原料费总成本
material_costs = costs[:, 0] * production
print(material_costs)
# 计算每个季度的人工费总成本
labor_costs = costs[:, 1] * production
print(labor_costs)
# 计算每个季度的管理费总成本
management_costs = costs[:, 2] * production
print(management_costs)
# 将数据写入 CSV 文件中
np.savetxt('cost_product.csv', quarterly_costs, delimiter=',')