Need this ASAP,
Don\'t forget to screenshot the script, output, and a
hand example
Due 11/28 Using nested for loops to A company produces types of parts from three different factories F1 F2 and Fs. These parts are to be shipped to a market from one of the factories. The first data table lists the quantities of parts each factory is capable of producing and the second gives the total cost of shipping these parts to a market. Design a program which determines which factory is to ship the order. The factory to be selected, in each case, is the one having the lowest shipping cost per unit for a particular part shipment. As always, be sure to include a hand example. Use the following pseudo code as a basis for your analysis (add or delete steps as you see fit) 1) Create the headings printed on the sample output 2) Treat the quantity and shipping costs as two-dimensional arrays called QUAN and COST 3) load the file (s)(which you create) 4) Form an outer loop for processing each of 5) Form an inner loop for computing the shipping cost per unit for each of the three factories for a particular part order: shipping cost Shipping cost per unit quantity 6) Determine the factory having the lowest shipping cost per unit Print the factory to be selected (see sample solution) 8) Repeat steps 5-7 for the next part order Data F1 Part 1 450 1 60 70 40 2 370 360 30 20 45 160 150 1300 1350 65 40 60 Sample solution output: Pactory Program to determine optimum supply Factory to supply parts Part Hand in: A printed copy of your script A printed copy of your output. A hand example for one case
print \"Program to determine optimum supply factory\"
QUAN = []
COST = []
f1 = open(\"cost.txt\",\"r\")
dat1 = f1.read().split(\"\ \")
for i in dat1:
c1 = i.split(\",\")
c = []
for j in c1:
c.append(int(j))
COST.append(c)
f2 = open(\"quan.txt\",\"r\")
dat2 = f2.read().split(\"\ \")
for i in dat2:
q1 = i.split(\",\")
q = []
for j in q1:
q.append(int(j))
QUAN.append(q)
print \"Part\\tFactory to supply part\"
for i in range(len(QUAN)):
mincost = 1000
ind = 0
for j in range(len(QUAN[i])):
sc = float(COST[i][j])/QUAN[i][j]
if(sc<mincost):
mincost = sc
ind = j
print i,\'\\t\\t\',ind+1
\"\"\"
cost.txt file
450,470,360
370,360,320
350,370,390
350,300,350
quan.txt file
60,70,40
30,20,30
45,60,50
65,40,60
sample output
Program to determine optimum supply factory
Part Factory to supply part
0 2
1 3
2 2
3 1
\"\"\"