Question: Write a function referencing the parameter dct to perform the following operations. Run the function using the dictionary called inventory as an argument.

Write a function referencing the parameter "dct" to perform the following operations. Run the function using the dictionary called "inventory" as an argument.
Start by printing the original dictionary:
{'iphone': 40, 'ipad': 17, 'macbook': 12, 'monitor': 5}
a. Add the key value pair "stylus": 16 and print the result.
{'iphone': 40, 'ipad': 17, 'macbook': 12, 'monitor': 5, 'stylus': 16}
b. Change the ipad inventory to 19 then print the result.
{'iphone': 40, 'ipad': 19, 'macbook': 12, 'monitor': 5, 'stylus': 16}
c. Remove the key value pair, "monitor": 5 then print the result.
{'iphone': 40, 'ipad': 19, 'macbook': 12, 'stylus': 16}
d. Extract each of the values in the dictionary and add them to the list called counts. Print the counts list.
[40,19,12,16]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!