Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python Problem A: Grocery Bag (10 points): In this problem you will create a series of functions that will allow a user to add grocery

pythonimage text in transcribedimage text in transcribedimage text in transcribed

Problem A: Grocery Bag (10 points): In this problem you will create a series of functions that will allow a user to add grocery items to a bag, take items out of the bag, lookup items in the bag, and show the entire contents of the bag. For this problem, vou will use a dictionarv to store the users grocerv items. The functions you will need to write are below (explanations for each function are in the constraints): de f loo kup (d, Item) : def subitem (d,item) : def addItem (d,item): def show (d): This problem will also require you to create a main function that will allow users to specify the actions they would like to occur. To make this program look nicer we will be using the Unicode characters to represent each food item. We have provided a list of food items and Unicode values for them. To get the Unicode character to appear in the terminal, you will need to use the chr0 function with the decimal representation of the Unicode character as the input. For example running print (chr(127822) into a Python interpreter would show an apple (try it). We have provided a table with all of the items we will be using in testing your programs and the Unicode values associated with them. You MUST implement all of the food items in the table. [hint: use a dictionary] Here is a sample output of your program. Your program needs to resemble this program completely. In your dictionary, the key should holds the item name and respective value should holds the number counts of that item. If an item is added to the dictionary for the first time, the item name should be added as the key and the value should be 1. Then if the item is added again the value should be incremented by 1 each time. If an item not in the dictionary is called in the functions lookup, show, or subItem then nothing should happen! Remember you are only using the Unicode values in the lookup and show functions! Problem A: Grocery Bag (10 points): In this problem you will create a series of functions that will allow a user to add grocery items to a bag, take items out of the bag, lookup items in the bag, and show the entire contents of the bag. For this problem, vou will use a dictionarv to store the users grocerv items. The functions you will need to write are below (explanations for each function are in the constraints): de f loo kup (d, Item) : def subitem (d,item) : def addItem (d,item): def show (d): This problem will also require you to create a main function that will allow users to specify the actions they would like to occur. To make this program look nicer we will be using the Unicode characters to represent each food item. We have provided a list of food items and Unicode values for them. To get the Unicode character to appear in the terminal, you will need to use the chr0 function with the decimal representation of the Unicode character as the input. For example running print (chr(127822) into a Python interpreter would show an apple (try it). We have provided a table with all of the items we will be using in testing your programs and the Unicode values associated with them. You MUST implement all of the food items in the table. [hint: use a dictionary] Here is a sample output of your program. Your program needs to resemble this program completely. In your dictionary, the key should holds the item name and respective value should holds the number counts of that item. If an item is added to the dictionary for the first time, the item name should be added as the key and the value should be 1. Then if the item is added again the value should be incremented by 1 each time. If an item not in the dictionary is called in the functions lookup, show, or subItem then nothing should happen! Remember you are only using the Unicode values in the lookup and show functions

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

What is meant by a firms positioning strategy?

Answered: 1 week ago

Question

What is cost plus pricing ?

Answered: 1 week ago

Question

1. What are the types of wastes that reach water bodies ?

Answered: 1 week ago

Question

Which type of soil has more ability to absorb water?

Answered: 1 week ago