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
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