1). Files, Lists, and Dictionaries: a). Write a function get_price() that asks the user to input prices for several items. The function first prompts the user to enter how many items he/she wants to record, then asks for the name and the price of each item. The function should store the user's input (names paired with prices) in a dictionary named dict_price. The function should return the dictionary. b). Call the function get_price() to create a dictionary. Then display the dictionary. c). Retrieve the keys in this dictionary (that is, the item names in this case) and put them into a list called item_list. Then write the item names into a txt file; each item should take a new line. d). Retrieve the values in this dictionary (that is, the item prices in this case) and put them into a list called price list. Then display the price list. e). Now we want to record the quantity sold for each item. Please write a function get_quantity() that uses the item_list and prompts the user to enter the quantity that has been sold for each item in this list, and creates a dictionary named dict_quantity, in which item names are paired with quantities. The function should return the dictionary. Then call the function and display the dictionary.
1). Files, Lists, and Dictionaries: a). Write a function get_price() that asks the user to input prices for several items. The function first prompts the user to enter how many items he/she wants to record, then asks for the name and the price of each item. The function should store the user's input (names paired with prices) in a dictionary named dict_price. The function should return the dictionary. b). Call the function get_price() to create a dictionary. Then display the dictionary. c). Retrieve the keys in this dictionary (that is, the item names in this case) and put them into a list called item_list. Then write the item names into a txt file; each item should take a new line. d). Retrieve the values in this dictionary (that is, the item prices in this case) and put them into a list called price list. Then display the price list. e). Now we want to record the quantity sold for each item. Please write a function get_quantity() that uses the item_list and prompts the user to enter the quantity that has been sold for each item in this list, and creates a dictionary named dict_quantity, in which item names are paired with quantities. The function should return the dictionary. Then call the function and display the dictionary.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question

Transcribed Image Text:1). Files, Lists, and Dictionaries:
a). Write a function get_price() that asks the user to input prices for several items. The function
first prompts the user to enter how many items he/she wants to record, then asks for the name
and the price of each item. The function should store the user's input (names paired with
prices) in a dictionary named dict_price. The function should return the dictionary.
b). Call the function get_price() to create a dictionary. Then display the dictionary.
c). Retrieve the keys in this dictionary (that is, the item names in this case) and put them into a
list called item_list. Then write the item names into a txt file; each item should take a new line.
4
d). Retrieve the values in this dictionary (that is, the item prices in this case) and put them into a
list called price list. Then display the price list.
e). Now we want to record the quantity sold for each item. Please write a function
get_quantity() that uses the item_list and prompts the user to enter the quantity that has been
sold for each item in this list, and creates a dictionary named dict_quantity, in which item
names are paired with quantities. The function should return the dictionary. Then call the
function and display the dictionary.
Show Transcribed Text
T
Sample input & output:
(Prompt) How many items do you want to record? (User enter) 2
(Prompt) Please enter the name for this item: (User enter) apple
(Prompt) Please enter the price for this item: (User enter) 3
(Prompt) Please enter the name for this item: (User enter) berry
(Prompt) Please enter the price for this item: (User enter) 4
![62°F
Sunny
(Output) The price dictionary is: {'apple': 3.0, 'berry': 4.0)
(Output) The price list is: [3.0, 4.0]
(Prompt) Please enter the quantity for apple: (User enter) 300
(Prompt) Please enter the quantity for berry: (User enter) 500
(Output) The quantity dictionary is: {'apple': 300.0, 'berry': 500.0)
* Although it won't show in the output here, but if everything goes correctly for part c), you
will have a txt file created in your computer with the item names in it.
Show Transcribed Text
dataquest e Collin College - Co...
ISQS 3345
Final Exam
Q Search
Exams Bb lear X Bb 409068 Bb 418238
Tuesday, Dec 5
2:00 pm - 3:10 pm
Ć
ChatGP E python +
☆
blackboard Google Docs raiderLink
https://learn-us-east-1-prod-fleet02...
O
AC](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F510cf9a2-5b3d-4df8-ac19-5a04f5d01d48%2F8ca9a234-e8d2-4eca-956d-f74f8aeefc2f%2F65xcfa8_processed.png&w=3840&q=75)
Transcribed Image Text:62°F
Sunny
(Output) The price dictionary is: {'apple': 3.0, 'berry': 4.0)
(Output) The price list is: [3.0, 4.0]
(Prompt) Please enter the quantity for apple: (User enter) 300
(Prompt) Please enter the quantity for berry: (User enter) 500
(Output) The quantity dictionary is: {'apple': 300.0, 'berry': 500.0)
* Although it won't show in the output here, but if everything goes correctly for part c), you
will have a txt file created in your computer with the item names in it.
Show Transcribed Text
dataquest e Collin College - Co...
ISQS 3345
Final Exam
Q Search
Exams Bb lear X Bb 409068 Bb 418238
Tuesday, Dec 5
2:00 pm - 3:10 pm
Ć
ChatGP E python +
☆
blackboard Google Docs raiderLink
https://learn-us-east-1-prod-fleet02...
O
AC
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education