Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that a company maintains multiple warehouses. Each warehouse stocks various products (not all warehouses stock the same products). The inventory of a product is

Suppose that a company maintains multiple warehouses. Each warehouse stocks various products (not all warehouses stock the same products). The inventory of a product is the amount of any product available at a warehouse. For example, a warehouse in Irvine 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 whose keys are the warehouses: associated with each warehouse is an inner dictionary whose keys are the stocked products (and whose associated values are the inventory of that product in the warehouse). The inventory must always be a non-negative value; an inventory of 0 is legal. For example, a simple/small database might be.

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 2 wallets.

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

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

I have printed this dictionary in an easy to read form. Python prints dictionaries on one line, and can print their key/values in any order, because dictionaries are not ordered. In the following function, do not mutate this dictionary; you can create local data structures in the functions and mutate them as necessary.

(b) The unique_suppler function a dictionary (dict or defaultdict) whose keys are str (the warehouse) and whose associated value is a set of all the products that are stocked only from that warehouse (even if the inventory shown there is 0): for the db dictionary above the result is {'Irvine': {'brush'}, 'Newport': {'stapler'}, 'Tustin': {'keychain', 'pencil'}}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

ISBN: 3030302776, 978-3030302771

More Books

Students also viewed these Databases questions