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.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 8PP: (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays...
icon
Related questions
Question
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
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
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
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
File Input and Output Operations
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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT