You are on page 1of 2

INVENTORY MANAGEMENT SYSTEM

(PYTHON FINAL PROJECT) - HADI

Create a console based inventory management system in python language in which you needs to
import json and create a blank dictionary named inventory and you have to display 5 options for a
user to choose one.

============================================================================

1) Please enter 1-Add New product


2) Please enter 2- Add Stock
3) Please enter 3- Sell Stock
4) Please enter 4- view product
5) Please enter 5- quit

Then take input the user choice.


Using if elif conditions call the corresponding functions of the user choice.

============================================================================

Function # 1

Create a function to add a new product in which you have to take input in the following variables

1) product_id
2) product_name
3) stock

Add product_name and stock to a dictionary p1.


Open inventory.json file for reading.
Retrieve the inventory dictionary using load function.

Assign p1 to the inventory dictionary with product_id as a key then dump the inventory
dictionary to an inventory.json file.
Code Hint
inventory[product_id] = p1
============================================================================

Function # 2
Create a function to add stock of the item in which you have to take input the product_id and stock
to be added in the following variables

1) product id
2) add_stock

Open an inventory.json file to read its data and search the corresponding product_id in the
retrieved inventory dictionary to access the stock against the product_id.

Code Hint
inventory = json.load(file_handle)
INVENTORY MANAGEMENT SYSTEM
(PYTHON FINAL PROJECT) - HADI

Add the new stock to the accessed stock and replace it to the position.

Code Hint
inventory[product_id][“ stock”] += add_stock

Again open an inventory.json file for writing purpose and dump the updated inventory dictionary
to the file.
============================================================================

Function # 3

Create a function to sell stock for which you have to take input the product_id and stock to be sold
in the following variables

1) product id
2) sell_stock

Open a inventory.json file to read its data and search the corresponding product_id in the
retrieved inventory dictionary to access the stock against the product_id.
Deduct the sell_stock from the accessed stock and replace it to the position.

Code Hint
inventory[product_id][“ stock”] -= sell_stock

Again open an inventory.json file for writing purpose and dump the updated inventory dictionary
to the file.
============================================================================

Function # 4

Create a function to view product of the inventory for which you have to take input the
product_id.

Open inventory.json file to read its data and search the corresponding product_id in the retrieved
inventory dictionary to access the product_name & stock against the product_id.
Display the product_name & stock.
============================================================================

NOTE: Repeat the process using while loop by setting Flag until user give input on each function to
end the program.

Best of luck

You might also like