Homework Assignment-1 Topics: Functions, Dictionary, Import Problem description: Write a python application to simulate an online clothing system. The purpose of this assignment is to gain experience in Python dictionary structure, create basic Python functions and import a module. Design solution: The template file contains a list of clothes item sold, each item in the list contains the item id, name of the item and the prices. The program will generate an items_dict where each key is the item id of the cloth and the values will be a list of item name and price information. A customer will be presented with a main menu with 4 different options: display all items, add an item to cart, checkout and exit the program. A customer can buy an item by entering the ID of the item. This program implements a dictionary called cart, where each key is the item id and the values are the list of name, price and quantity that user chooses to purchase. The program keeps repeating by displaying the main menu to user until user hits the quit button. If user hits the checkout option, the program will display all the items in the cart and display the total amount purchased. Implementation: 1. This program will require to use two .py files: utility and application files. utility file contains all the helper functions. The application file contains the main functionality of the program. One helpful example can be: how to import a module. 2. This program requires to implement two dictionaries: items_dict and cart. items_dict will be populated from the given list of clothes at the beginning of the program. Each key will be the item id and the value will be a list of item name and price. cart dictionary will be a subset of items_dict that contains all the items user wants to purchase. The structure will be same as items_dict except the value list will contain name, price and quantity of the item. 3. The application file will contain a main function. main function implements the user menu and calls all the functions from the utility file. Hint: How to import a function from one file to another? 4. Utility file will contain the following function definitions. All these function call will be made from application file. a. build_dict(items): Returns items_dict from items list. items list is provided in the template file. This function is defined in the utility file and will be called from the application file at the beginning of the program.  b. checkout(cart): Returns the total amount purchased using the user cart. This function will be called when user chooses to checkout for option 3. cart contains all the items user is purchasing. checkout function will get the price and quantity of an item from the cart dictionary and returns the total amount by multiplying price with quantity. Hint: price of an item is the -2 index and quantity at -1 index from the cart’s value list. c. display_all_items(d): Takes any dictionary d and display all the items in the dictionary. This function will be called for menu option 1 and option 3. Hint: How to print a dictionary? d. add_to_cart(item_id, cart, items_dict): Add an item to cart from the items_dict if item id exists in the items_dict. For menu option 2, user will provide the item id. If id exists then item will be added to the cart. Upon successful addition the function will return True otherwise returns False.

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
icon
Related questions
Question

Homework Assignment-1
Topics: Functions, Dictionary, Import
Problem description: Write a python application to simulate an online clothing system. The
purpose of this assignment is to gain experience in Python dictionary structure, create basic
Python functions and import a module.
Design solution: The template file contains a list of clothes item sold, each item in the list
contains the item id, name of the item and the prices. The program will generate an items_dict
where each key is the item id of the cloth and the values will be a list of item name and price
information. A customer will be presented with a main menu with 4 different options: display
all items, add an item to cart, checkout and exit the program. A customer can buy an item by
entering the ID of the item. This program implements a dictionary called cart, where each key is
the item id and the values are the list of name, price and quantity that user chooses to
purchase. The program keeps repeating by displaying the main menu to user until user hits the
quit button. If user hits the checkout option, the program will display all the items in the cart
and display the total amount purchased.
Implementation:
1. This program will require to use two .py files: utility and application files. utility file
contains all the helper functions. The application file contains the main functionality of
the program. One helpful example can be: how to import a module.
2. This program requires to implement two dictionaries: items_dict and cart. items_dict
will be populated from the given list of clothes at the beginning of the program. Each
key will be the item id and the value will be a list of item name and price. cart dictionary
will be a subset of items_dict that contains all the items user wants to purchase. The
structure will be same as items_dict except the value list will contain name, price and
quantity of the item.
3. The application file will contain a main function. main function implements the user
menu and calls all the functions from the utility file. Hint: How to import a function from
one file to another?
4. Utility file will contain the following function definitions. All these function call will be
made from application file.
a. build_dict(items): Returns items_dict from items list. items list is provided in the
template file. This function is defined in the utility file and will be called from the
application file at the beginning of the program. 

b. checkout(cart): Returns the total amount purchased using the user cart. This
function will be called when user chooses to checkout for option 3. cart contains
all the items user is purchasing. checkout function will get the price and quantity
of an item from the cart dictionary and returns the total amount by multiplying
price with quantity. Hint: price of an item is the -2 index and quantity at -1 index
from the cart’s value list.
c. display_all_items(d): Takes any dictionary d and display all the items in the
dictionary. This function will be called for menu option 1 and option 3. Hint: How
to print a dictionary?
d. add_to_cart(item_id, cart, items_dict): Add an item to cart from the items_dict
if item id exists in the items_dict. For menu option 2, user will provide the item
id. If id exists then item will be added to the cart. Upon successful addition the
function will return True otherwise returns False. 

b. checkout(cart): Returns the total amount purchased using the user cart. This
function will be called when user chooses to checkout for option 3. cart contains
all the items user is purchasing. checkout function will get the price and quantity
of an item from the cart dictionary and returns the total amount by multiplying
price with quantity. Hint: price of an item is the -2 index and quantity at -1 index
from the cart's value list.
c. display_all_items(d): Takes any dictionary d and display all the items in the
dictionary. This function will be called for menu option 1 and option 3. Hint: How
to print a dictionary?
d. add_to_cart(item_id, cart, items_dict): Add an item to cart from the items_dict
if item id exists in the items_dict. For menu option 2, user will provide the item
id. If id exists then item will be added to the cart. Upon successful addition the
function will return True otherwise returns False.
Sample I/O:
Welcome to 109 clothing store!
1. Display all item
2. Purchase clothes
3. Checkout
Enter your option: 1
ID-Item name-Price
ID1-AX Jacket-202.99
ID100-RL Polo-60.99
ID23-AK Tops- 19.99
ID34-Levis Jeans-65.78
1. Display all item
2. Purchase clothes
3. Checkout
Enter your option: 2
Enter the ID of the item to add: ID1
Enter the quantity: 2
2 of ID1 added to cart
Transcribed Image Text:b. checkout(cart): Returns the total amount purchased using the user cart. This function will be called when user chooses to checkout for option 3. cart contains all the items user is purchasing. checkout function will get the price and quantity of an item from the cart dictionary and returns the total amount by multiplying price with quantity. Hint: price of an item is the -2 index and quantity at -1 index from the cart's value list. c. display_all_items(d): Takes any dictionary d and display all the items in the dictionary. This function will be called for menu option 1 and option 3. Hint: How to print a dictionary? d. add_to_cart(item_id, cart, items_dict): Add an item to cart from the items_dict if item id exists in the items_dict. For menu option 2, user will provide the item id. If id exists then item will be added to the cart. Upon successful addition the function will return True otherwise returns False. Sample I/O: Welcome to 109 clothing store! 1. Display all item 2. Purchase clothes 3. Checkout Enter your option: 1 ID-Item name-Price ID1-AX Jacket-202.99 ID100-RL Polo-60.99 ID23-AK Tops- 19.99 ID34-Levis Jeans-65.78 1. Display all item 2. Purchase clothes 3. Checkout Enter your option: 2 Enter the ID of the item to add: ID1 Enter the quantity: 2 2 of ID1 added to cart
Homework Assignment-1
Topics: Functions, Dictionary, Import
Problem description: Write a python application to simulate an online clothing system. The
purpose of this assignment is to gain experience in Python dictionary structure, create basic
Python functions and import a module.
Design solution: The template file contains a list of clothes item sold, each item in the list
contains the item id, name of the item and the prices. The program will generate an items_dict
where each key is the item id of the cloth and the values will be a list of item name and price
information. A customer will be presented with a main menu with 4 different options: display
all items, add an item to cart, checkout and exit the program. A customer can buy an item by
entering the ID of the item. This program implements a dictionary called cart, where each key is
the item id and the values are the list of name, price and quantity that user chooses to
purchase. The program keeps repeating by displaying the main menu to user until user hits the
quit button. If user hits the checkout option, the program will display all the items in the cart
and display the total amount purchased.
Implementation:
1. This program will require to use two.py files: utility and application files. utility file
contains all the helper functions. The application file contains the main functionality of
the program. One helpful example can be: how to import a module.
2. This program requires to implement two dictionaries: items_dict and cart. items_dict
will be populated from the given list of clothes at the beginning of the program. Each
key will be the item id and the value will be a list of item name and price. cart dictionary
will be a subset of items_dict that contains all the items user wants to purchase. The
structure will be same as items_dict except the value list will contain name, price and
quantity of the item.
3. The application file will contain a main function. main function implements the user
menu and calls all the functions from the utility file. Hint: How to import a function from
one file to another?
4. Utility file will contain the following function definitions. All these function call will be
made from application file.
a. build_dict(items): Returns items_dict from items list. items list is provided in the
template file. This function is defined in the utility file and will be called from the
application file at the beginning of the program.
Transcribed Image Text:Homework Assignment-1 Topics: Functions, Dictionary, Import Problem description: Write a python application to simulate an online clothing system. The purpose of this assignment is to gain experience in Python dictionary structure, create basic Python functions and import a module. Design solution: The template file contains a list of clothes item sold, each item in the list contains the item id, name of the item and the prices. The program will generate an items_dict where each key is the item id of the cloth and the values will be a list of item name and price information. A customer will be presented with a main menu with 4 different options: display all items, add an item to cart, checkout and exit the program. A customer can buy an item by entering the ID of the item. This program implements a dictionary called cart, where each key is the item id and the values are the list of name, price and quantity that user chooses to purchase. The program keeps repeating by displaying the main menu to user until user hits the quit button. If user hits the checkout option, the program will display all the items in the cart and display the total amount purchased. Implementation: 1. This program will require to use two.py files: utility and application files. utility file contains all the helper functions. The application file contains the main functionality of the program. One helpful example can be: how to import a module. 2. This program requires to implement two dictionaries: items_dict and cart. items_dict will be populated from the given list of clothes at the beginning of the program. Each key will be the item id and the value will be a list of item name and price. cart dictionary will be a subset of items_dict that contains all the items user wants to purchase. The structure will be same as items_dict except the value list will contain name, price and quantity of the item. 3. The application file will contain a main function. main function implements the user menu and calls all the functions from the utility file. Hint: How to import a function from one file to another? 4. Utility file will contain the following function definitions. All these function call will be made from application file. a. build_dict(items): Returns items_dict from items list. items list is provided in the template file. This function is defined in the utility file and will be called from the application file at the beginning of the program.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Dictionary
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
Database System Concepts
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education