Menu

Suppose Company Maintains Multiple Warehouses Warehouse Stocks Various Products Warehouses Q43885528

Suppose that a company maintains multiple warehouses. Eachwarehouse stocks various products (not all warehouses stock thesame products). The inventory of a product is the amount of anyproduct available at a warehouse. For example, a warehouse inIrvine may stock a brush product, and it may have an inventory of 3(3 brushes in the Irvine warehouse).

We will represent all this information in a dictionary whosekeys are the warehouses: associated with each warehouse is an innerdictionary whose keys are the stocked products (and whoseassociated values are the inventory of that product in thewarehouse). The inventory must always be a non-negative value; aninventory of 0 is legal. For example, a simple/small database mightbe.

db = {‘Irvine’ : {‘brush’: 3, ‘comb’: 2, ‘wallet’: 2},’Newport’: {‘comb’: 7, ‘stapler’: 0},
‘Tustin’ : {‘keychain’: 3, ‘pencil’: 4, ‘wallet’: 3}}

This data structure means that

  1. The Irvine warehouse stocks 3 brushes, 2 combs, and 2wallets.

  2. The Newport warehouse stocks 7 combs, and 0 staplers.

  3. The Tustin warehouse stocks 3 keychains, 4 pencils, and 3wallets.

I have printed this dictionary in an easy to read form. Pythonprints dictionaries on one line, and can print their key/values inany order, because dictionaries are not ordered. In the followingfunction, do not mutate this dictionary; you can create local datastructures in the functions and mutate them as necessary.

(b) The unique_suppler function a dictionary (dict ordefaultdict) whose keys are str (the warehouse) and whoseassociated value is a set of all the products that are stocked onlyfrom that warehouse (even if the inventory shown there is 0): forthe db dictionary above the result is {‘Irvine’: {‘brush’},’Newport’: {‘stapler’}, ‘Tustin’: {‘keychain’, ‘pencil’}}

Expert Answer


Answer to Suppose that a company maintains multiple warehouses. Each warehouse stocks various products (not all warehouses stock t…

OR