Task:
You are to plan and then code a console-based program in Python 3, as described in the following information and sample output. This assignment will help you build skills using selection, repetition, file input/output, exceptions, lists/tuples, functions and string formatting. Do not to define any of your own classes. Assignment 2 will build on this program with more advanced code constructs including classes and a Graphical User Interface (GUI). Work incrementally on this task: complete small parts of it at a time rather than trying to get it all working at once.
Program Overview:
This program is a simple shopping list that could also be used for TODOs or similar purposes. The program maintains a list of items in a file, and each item has:
- name, price, priority (1, 2 or 3), whether it is required or completed
Users can choose to see the list of required items or completed items, including a total of the (estimated) price of all of those items. The lists will be sorted by priority.
Users can add new items and mark items as completed.
They can't change items from completed to required.
Program Functionality Details:
Ensure that your program has the following features, as demonstrated in the sample output below.
Your program should:
- display a welcome message with your name in it
- display a menu for the user to choose from
- return to the menu and loop until the user chooses to quit
- error-check user inputs as demonstrated in the sample output
- start by loading a CSV (Comma Separated Values) file of items that are in stock for hire;
a sample CSV file is provided for you
- (when the user chooses list) display a neatly formatted list of all the required items with their prices lined up and priorities
- (when the user chooses show completed) display a similarly formatted list of completed items
- (when the user chooses add) prompt for the item's name, price and priority, error-checking each of these, then add the item to the list in memory
- (when the user chooses complete) display the same list of required items, then allow the user to choose one (error-checked), then change that item to completed
o if no items are required, then a message should be displayed and the user returned to the menu
- (when the user chooses quit) save the items to the CSV file, overwriting the file contents
Coding Requirements and Suggestions:
- Make use of named constants where appropriate.
- Use functions appropriately for each significant part of the program: this is the divide-and-conquer problem-solving approach. Remember that functions should "do one thing".
Look for situations where functions can be used to reduce code duplication (e.g. displaying the completed and required lists is very similar).
- For efficiency, you should only load the items file once. Store the results appropriately in a list of lists that you can pass to any functions that need access to it.
- Note that the menu choice should handle uppercase and lowercase letters.
- Use exception handling where appropriate to deal with input errors (including entering numbers and selecting items).
- Check the rubric carefully to see any other aspects of the coding that you will be assessed on.
Output Requirements:
Sample output from the program is provided below. Ensure that your program matches the sample output including spaces, spelling, and especially the formatting of the item lists. Think of this as helpful guidance as well as training you to be particular and pay attention to detail. The sample output is intended to show the full range of situations including user input error handling.