Question
IN PYTHON 3 LANGUAGE write a function named resupply that takes a dict argument: each key in the dict is a str (the warehouse) whose
IN PYTHON 3 LANGUAGE write a function named resupply that takes a dict argument: each key in the dict is a str (the warehouse) whose associated value is another dict: this inner dict associates a str (the product) with an int (the inventory) and a second argument that is an int specifying the desired minimum inventory of every product: a warehouse must have at least that inventory for every product in the warehouse.
For example, the db1.txt file contains the lines brush:Irvine:3 comb:Irvine:2:Newport:1 wallet:Irvine:2:Tustin:3 stapler:Newport:0 keychain:Tustin:3 pencil:Tustin:4
db: {'Irvine': {'brush': 3, 'comb': 2, 'wallet': 2}, 'Newport': {'comb': 1, 'stapler': 0}, 'Tustin' : {'keychain': 3, 'pencil': 4, 'wallet': 3}} DESIRED OUTPUT: Calling this function with the db dictionary shown on the top of page 2 resupply( db , 3 ) returns a dictionary whose contents are: {'comb': {('Irvine', 1), ('Newport', 2)}, 'wallet': {('Irvine', 1)}, 'stapler': {('Newport', 3)}} *Note that for combs, Irvine needs to resupply 1 and Newport needs to resupply 2 to bring their inventories up to 3. For wallets, Irvine needs to resupply 1. For staplers, Newport needs to resupply 3. For pencils, brushes, and keychains, all stores stocking these products have an inventory >=3 so those products don't appear as keys in the resulting dictionary.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started