Py Lab S 21-PROJ Description PDF

Title Py Lab S 21-PROJ Description
Course Database Management and Interfacing
Institution Algonquin College
Pages 4
File Size 119.6 KB
File Type PDF
Total Downloads 86
Total Views 128

Summary

Description...


Description

Python project: Inventory Management System Program description  



The inventory program is named inventory_.py. Example: inventory_smit0001.py. The inventory program manages an inventory file. o The inventory file is a structured file and contains the item name and the date the item has been added, one item per line. o Select the type of items you want to inventory (for example: computer hardware) and name your inventory file appropriately. Example: hardware_inventory.txt. The inventory program has the following functionality: o Displays the inventory: displays all items currently recorded in the inventory file. o Searches the inventory: searches the inventory for an item entered by the user. o Adds an item to the inventory: adds an item entered by the user to the inventory. o Provides an option to quit the program. Note: Use flow control to exit the program, not a function call.

Program functions The inventory program includes the following functions. 

Create the following functions: o show_menu() # display menu o get_menu_option() # prompt user for menu option o get_item() # prompt user for an inventory item o isinventoried() # determine if an item exists in the inventory o show_inventory() # display inventory Note: We assume unique entries for each item, that is: there are no duplicates. o add_inventory() # write host information to hosts file



Function details o show_menu()  Function purpose: display the following menu options: display inventory, search inventory, add to inventory, quit.  Function parameters: none  Function return: none o get_menu_option()  Function purpose: prompt user for menu option  Function parameters: prompt (example: “Enter menu selection: “)  Function return: user input o get_item()  Function purpose: prompt user for item to add to or lookup in inventory

  

o

Function parameters: prompt Function return: user input Function body: Verify that the user inputted data at the prompt (rather than hitting Enter without data). Re-prompt for an item if necessary. Note: Remember that Python is case-sensitive. isinventoried()  Function purpose: determine if an item exists in the inventory  Function parameters: inventory file, item to lookup  Function return: True/False  Function body: Open the file in read mode using the with keyword; return ‘None’ if an exception occurs.  Search for item in file  Return True if found, False otherwise show_inventory()  Function purpose: display inventory  Function parameters: inventory file  Function return: none  Function body: 

o

o

 Open the file in read mode; return ‘None’ if an exception occurs.  Display all items in inventory. add_inventory()  Function purpose: write an item to the inventory file  Function parameters: inventory file, item  Function return: none  Function body:  Open file in append mode.  Append item with current date to inventory. Note: To append the current date use the following statements: o Import the module datetime. o In your function that writes to the inventory use the following argument for the current date: str(datetime.date.today()).

Main program The main program consists of a skeleton program with flow control:  A main loop that prompts the user for a menu selection.  A decision based on the user selection. o If the menu option is to display the inventory, display all inventory items. o If the menu option is to lookup an item, determine if the item exists in the inventory and display an appropriate message for either case.

o o o

If the menu option is to add an inventory item verify first that the item exists before adding it to the inventory. Display an appropriate message for either case. If the user select to quit close the program using flow control structure. If the user selects an invalid option display an appropriate message.

Within each decision branch write appropriate code and call the corresponding functions to complete the requested menu task.

Sample runs Note: The output does not have to match exactly, but has to have a similar format & be userfriendly. [u8245 @localhost ~] $ ./inventory_smit0001.py “Inventory Management System” 1. Display inventory 2. Search inventory 3. Add to inventory Q. Quit Enter menu option: 1 router 2020-11-11 server 2020-12-24 laptop 2021-03-20 desktop 2021-03-20 Enter menu option: 2 Enter item to look up: Server Item ‘server’ in inventory. Enter menu option: 2 Enter item to look up: Item cannot be an empty string. Enter item to look up: ups Item ‘ups’ not in inventory. Enter menu option: 3 Enter new item to add: ups Item ‘ups’ added to inventory. Enter menu option: 3 Enter new item to add: ups Item ‘ups’ already in inventory. Enter menu option: 5

Invalid option. Enter menu option: q [u8245 @localhost ~] $...


Similar Free PDFs