Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please show all work! This class is about python don’t use any other programs. 2

ID: 3750098 • Letter: P

Question

Please show all work! This class is about python don’t use any other programs. 2. (25 pts) Consider the following table that gives inventory information for a set of products in a distribution center. For each product, the Weight is the product weight in pounds, the Cost is the wholesale cost in dollars, the Qty is the quantity on hand, and the Leadtime is the number of days required to replenish the stock Weight Cost Qty Leadtime Item A104 A206 B968 C1807 12.52 | 11.50 | 121 6.05 76.0032 18 14.75 29 0.23 128.18 12 18 Give the Python statement to create a dictionary of lists for this data, using the Item as the dictionary key a. Assume this data structure to answer the following questions: b. Give the Python statement to change the cost of B968 to 129.00 c. Give a Python comprehension that creates a list of the item Leadtimes d. Give a single Python statement using a comprehension to compute the total inventory value e. Give a single Python statement to add a new item (D2164) with weight-16; cost 1.25; qty-100; and leadtime-10

Explanation / Answer

Below are the answers for your questions. Please drop a comment if you have any doubts. Thank you.

a)

'''creating a dictionary of inventory items using item code as key and a list containing other attributes as value'''

inventory={'A104':[12.52,11.50,121,5],

'A206':[6.05,76.00,32,6],

'B968':[0.23,128.18,18,12],

'C1807':[8.19,14.75,29,18]}

b)

'''changing the cost of item with id B968 to 129.00'''

inventory['B968'][1]=129.00

c)

'''creating a list of lead times of all items in the inventory, using a list comprehension'''

lead_times=[x[3] for x in inventory.values()]

d)

'''finding the total inventory value (cost of all items) in the inventory, using a list comprehension of cost values and calling the sum() method'''

total_inventory_value=sum([x[1] for x in inventory.values()])

e)

'''adding a new entry to the inventory with key D2164 and given values'''

inventory['D2164']=[16,1.25,100,10]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote