Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For a given dictionary, named inventory, Inventory a purchase 'bag': [ ' apple ' , 'bread', 'milk' ] , pack'! [ ' canvas ' ,

For a given dictionary, named inventory, Inventory a purchase 'bag': ['apple', 'bread', 'milk'], pack'! ['canvas', 'paper', 'rope', 'loat') try to do the followings: * Add a key to inventory called 'pocket. Set the value of 'pocket' to be a list consisting of the strings: 'shell', berry, and 'mint' Remove("poper') from the list of items stored under the 'pock' key. Add 50 to the number stored under the 'purchase' key. Activity -2: Define the following two dictionaries: prices -(banana": 4, "apple*t 2, "orange": 1.5, "pear": J) stock -("banana" : 6, "apple"t 0, "orange"s 92, "pear", 15) Loop through euch key in prices. For euch key, print out the key along with its price and stock information. Print the answer in the following format: apple price: 2 stock: 0 Let's determine how much money you would moke if you sold all your food. Creole a voroble colled totoi and set it to zero.. Loop through the prices dietionaries. For eoch key in prices, multiply the number in prices by the number in stock. Print that value into the console and then add it to totol. Finally, outside your loop, print total 1[Page For the two dictionaries (stock and prices) you made in previous example, make a list called shopping_ list with the values: "banana" STOCK =1/ "apple"r "orange": 32, prices =( "apple": oranre 12.5 Define a function compute_ bill that takes one arguent food as input. in the function. crete a voriable total with on initial value of zero. While you loop through eoch item of food, only add the price of the item to total if the item's stock count is greater than zero. the item a in stock and ofter you odd the price to the fotol subtract one from the flem'

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions

Question

What are related party transactions? Discuss.

Answered: 1 week ago