If a matching product is found and the stock level of that product is at least?

If a matching product is found and the stock level of that product is at least?

In Python and in one file please. (Simple functions with an expressions) Create a function called load_inventory(filename). The filename argument in this case specifies the name of a file that contains all the inventory/product information for the store, including product names, descriptions, prices, and stock levels. This function should clear any information already in the product list (i.e., a fresh start) and then re-initialize the product list using the file specified by the filename argument. You can structure your file any way you like, but a suggested line-by-line structure like given below: Desktop Computer 3Ghz, 16GB RAM, 250GB Hard Drive 1200 10 Laptop Computer 2.5Ghz, 8GB RAM, 128GB Hard Drive, 15″ Screen 1500 15 Add another function to the a4.py file called save_inventory(filename). This function should save all the product list information into the file with the specified name. It should also overwrite any data that is already in the file. Once you have defined both the save and load inventory functions, you will be able to load a stored information, perform some changes using the other functions, then save those changes back to the file so they are remembered when the program restarts and the file is loaded again. Add another function to the a4.py file called add_new_product(name, desc, price, stock). This function accepts four arguments representing the information for a new product. It should add that new product to the store’s product list only if no other product in the store’s product list has the same name (case should be ignored, so “Tablet” and “tablet” would be considered the same name). This will ensure the names of products in the store are unique, which will be important to remove ambiguity in other functions (e.g., one that removes products by name). This function must return True to indicate the product was successfully added or False to indicate the product was not added. Add another function to the a4.py file called remove_product(name). This function must go through the store’s product list and remove a product from the list if that product’s name matches the given name argument (again, this should not be case sensitive). The function should return True to indicate a product was removed and False if a product was not removed. Add another function to the a4.py file called add_product_stock(name, units). This function must search through the store’s product list to find a product with the matching name. If a matching product is found, the stock of that product in the store should be increased by the given number of units. The function should return True to indicate the stock level of a product was updated and False to indicate no updates were made (e.g., if a product was not found with that name). Add another function to the a4.py file called sell_product(name, units). This function must search through the store’s product list to find a product with the matching name. If a matching product is found and the stock level of that product is at least the number of units specified (i.e., the store has that many units available to sell), then the stock level of that product should be decreased by the specified number of units. This function must return True to indicate that a product was found and the stock was updated. If a product with that name is not found or there are not enough units in stock to complete the sale, the function must return False. Add another function to the a4.py file called list_products(keyword). This function will search through the list of products and print out those that match the given keyword argument. If the keyword is “*”, then all products should be considered a match (essentially, this prints the entire store inventory). Otherwise, a product should match the keyword if that keyword is contained either in the product name or the product description (not case sensitive, “tablet” should match “Tablet”, and “TABLET”, etc.). The printout should format the product information in an easy to read fashion that includes the name, description, price and number of units in stock. Add a final function to the a4.py file called main(). This function must print out a menu with the 9 options detailed in the table below and allow the user to repeatedly enter choices until they chose to quit. An example of what the output might look like here: his is example output created by the main() function when it is run. The inventory.txt file that is loaded in this example is included on the assignment. You can use it as a starting point for your own file or create your own by adding products through the menu. Choose an option below to proceed: 1. Load Inventory 2. Save Inventory 3. Add New Product 4. Add Product Stock 5. List Products 6. Search Products 7. Sell Products 8. Remove Product 9. Quit >5 There are no products that match. Choose an option below to proceed: 1. Load Inventory 2. Save Inventory 3. Add New Product 4. Add Product Stock 5. List Products 6. Search Products 7. Sell Products 8. Remove Product 9. Quit >1 Enter the file name to load from:inventory.txt Choose an option below to proceed: 1. Load Inventory 2. Save Inventory 3. Add New Product 4. Add Product Stock 5. List Products 6. Search Products 7. Sell Products 8. Remove Product 9. Quit >5 1. Desktop Computer, 3Ghz, 16GB RAM, 250GB Hard Drive, $1200.0, 10 units in stock 2. Laptop Computer, 2.5Ghz, 8GB RAM, 128GB Hard Drive, 15″ Screen, $1500.0, 15 units in stock


 

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

The post If a matching product is found and the stock level of that product is at least? appeared first on nursing assignment tutor.