Question

In: Computer Science

(Please use Python) Suppose that a company sells five products with product codes p101, p107, p122,...

Suppose that a company sells five products with product codes p101, p107, p122, p125, and p126. The company has three warehouses, which are located in St. Louis, Chicago, and Kansas City. The retail value for each of the five products and the inventory for each of the warehouses are stored in dictionaries, as shown below.

Copy the code below into a code cell, and then execute that cell.

prices = {'p101':37.52, 'p117':56.98, 'p122':43.72, 'p125':48.33, 'p126':52.45}

inventory = { 'STL':{'p101':520, 'p117':315, 'p122':117, 'p125':258, 'p126':345}, 'CHI':{'p101':125, 'p117':864, 'p122':231, 'p125':612, 'p126':164}, 'KC' :{'p101':264, 'p117':285, 'p122':772, 'p125':467, 'p126':106} }

We will create a new dictionary named total_inventory that contains 5 key/value pairs. The keys should be product ids and the values should be the total quantity for that product across all three warehouses.

An outline of this process is provided for creating total_inventory is provided below:

1. Create an empty dictionary named total_inventory.

2. Loop over the keys of prices. Note that each key refers to a product id. I recommend using a variable name similar to prod_id for the loop variable. For each iteration of the loop:

a. Set a variable named quantity equal to 0.

b. Loop over the values of the elements stored in inventory. Note that these values are themselves dictionaries, and that they store the inventories for each site. For each such site inventory, use the current product id form the outer loop to extract the quantity of that product at the current site. Add this quantity to quantity.

c. Add prod_id / quantity as a new new/value pair in total_inventory.

Display the results by looping over the key/value pairs in total_inventory. Each time the loop executes, print out the pair in the following format: key: value

We will now calculate the total value of the company’s inventory.

Create a new code cell to perform the following steps:

1. Set total_value equal to 0.

2. Loop over the keys (product ids) stored in prices. Each time the loop executes:

a. Use the current product id to extract the associated values from the dictionaries prices and total_inventory.

b. Multiply these values found in Part a together and add the result to total_value.

Print the result with a message as follows:

A company sells two products, A and B. Product A Product B Produced and sold 8.000...
A company sells two products, A and B. Product A Product B Produced and sold 8.000 units 16.000 units Sale price per unit 65 52 Variable cost per unit 35 30 Fixed cost per unit 15 15 Fixed cost is divided in a traditional way, based on the produced quantity. The company started to design a new product C to replace product B. The company could sell 11.000 units of product C with a selling price of 80 per unit....
Please attach the output screenshots, narrative descriptions, or paste the Python codes when requested. Task 2...
Please attach the output screenshots, narrative descriptions, or paste the Python codes when requested. Task 2 We are producing two types of products, product A and product B. Product A is defective if the weight is greater than 10 lbs. Product B is defective if the weight is greater than 15 lbs. For a given product, we know its product_type and its weight. Design a program to screen out defective products. Starting the program with variable definition: product_type = 'xxx'...