Need help with your Discussion

Get a timely done, PLAGIARISM-FREE paper
from our highly-qualified writers!

glass
pen
clip
papers
heaphones

Functions Dictionary Import Files Project

Functions Dictionary Import Files Project

Functions Dictionary Import Files Project

Description

Topics: Functions, Dictionary, Import, Files 

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. This homework is based on Homework – 3 and will be a helpful resource for your final project. This program is similar to HA-3 the only difference is that it uses files read operation along with dictionary data structure. 

Design solution: An input file input_HA4.txt is given – contains clothes item sold, one item per line and each line contains the item id, name of the item and the prices. The program will generate an items dictionary where each key is the item id of the cloth and the values will be a list of item name and price information from reading the file information. A customer will be presented with a main menu with 4 different options: display all items, add an item to cart by ID, purchase item by price range, 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 exit 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 discussed so far.

2. This program requires to implement two dictionaries: items and cart. items will be populated from the given input file 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 dictionary 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(): Returns items dict from input_HA4.txt input file. read each line of the file, separate the information to identify the key and value to add an item to the items dictionary. This function to be 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. 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 purchasing options. Hint: How to print a dictionary using a for loop?

d. add_to_cart_by_ID(user_id, user_quantity, cart, items): Add an item to cart from the items dict if item id exists. User will provide the item id. If it exists then item will be added to the cart. Upon successful addition the function will return True otherwise returns False. 

e. display_item_by_price_range(min_price, max_price, items): display an item if it falls withing the user given price from the items dict. It will return True if items are found within the range otherwise returns False. Same as HA-3 implementation except using a dictionary. 

Sample I/O: 

Welcome to Shopping IT109!

**** Following items are available in the store **** 

ID-Item name-Price

ID1-AX Jacket-202.99

ID100-RL Polo-60.99

ID23-AK Tops- 19.99 

ID34-Levis Jeans-65.78

[id] Purchase item by name

[p] Purchase item by price range 

[c] Checkout Please input an option or type ‘e’ to exit the program: p

Enter min price: 10

Enter max price: 70

ID100-RL Polo-60.99

ID23-AK Tops- 19.99

ID34-Levis Jeans-65.78

Enter the ID of the item: ID100

Enter the quantity: 4

4 of ID100 added to your cart

**** Following items are available in the store **** 

ID-Item name-Price 

ID1-AX Jacket-202.99

ID100-RL Polo-60.99

ID23-AK Tops- 19.99

ID34-Levis Jeans-65.78 

[id] Purchase item by name 

[p] Purchase item by price range

[c] Checkout Please input an option or type ‘e’ to exit the program: ID 

Enter the ID of the item: ID34

Enter the quantity: 1

1 of ID34 added to your cart

**** Following items are available in the store ****

ID-Item name-Price

ID1-AX Jacket-202.99 

ID100-RL Polo-60.99

ID23-AK Tops- 19.99 

ID34-Levis Jeans-65.78

Please input an option or type ‘e’ to exit the program: P 

Enter min price: 300

Enter max price: 400 

No item found within the price range. #error message

[id] Purchase item by name

[p] Purchase item by price range 

[c] Checkout Please input an option or type ‘e’ to exit the program: C 

Thanks for shopping with us. 

**** You purchased the following item(s) ****

ID-Item name-Price-Quantity 

ID100-RL Polo-60.99-4

ID34-Levis Jeans-65.78-1 

The total amount is: $309.74 

**** Following items are available in the store **** 

ID-Item name-Price 

ID1-AX Jacket-202.99 

ID100-RL Polo-60.99

ID23-AK Tops- 19.99 

ID34-Levis Jeans-65.78 

[id] Purchase item by name 

[p] Purchase item by price range

[c] Checkout Please input an option or type ‘e’ to exit the program: E

>>>

This information in the txt file; 

ID1,AX Jacket,202.99

ID100,RL Polo,60.99

ID23,AK Tops, 19.99 

ID34,Levis Jeans,65.78

Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."

Order Solution Now

Our Service Charter


1. Professional & Expert Writers: Eminence Papers only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided by Eminence Papers are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Eminence Papers are known for the timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Eminence Papers, we have put in place a team of experts who answer all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.

We Can Write It for You! Enjoy 20% OFF on This Order. Use Code SAVE20

Stuck with your Assignment?

Enjoy 20% OFF Today
Use code SAVE20