Question
I have already done almost my code on phyton I just need to add some new variable which is given below code on pic I
I have already done almost my code on phyton I just need to add some new variable which is given below code on pic I need to add these items there kindly add me these code on my this program and also mentioned comment how he added and what the function of that code too ...
Code
import datetime
inventory = dict()
run = True
def display_item(value): print('Item Category: ' + value['category']) print('Item Price: ' + str(value['price'])) print('Item Description: ' + value['description']) print('Item Weight or Volume: ' + str(value['weight'])) print('Item Quantity: ' + str(value['quantity'])) print('Item Creation Time: ' + str(value['creation_time']))
def display_menu(): print('Inventory Control System') print('\t[1]\tAdd Item') print('\t[2]\tUpdate Item Level') print('\t[3]\tRemove Item') print('\t[4]\tList Inventory') print('\t[5]\tShow Items whose quantity
def addItem(): print('Stock Control - Add Item:') print('=========================') itemCategory = input('Enter Item Category: ') itemNameCode = input('Enter Item Name Code: ') itemPrice = float(input('Enter Price Per Item (QR): ')) itemDescription = input('Enter Item Description: ') itemWeightOrVolume = float(input('Enter Weight or Volume for Each Item: ')) itemquantity = int(input('Enter quantity: ')) itemCreationTime = datetime.datetime.now() save = input('Save (Y/N): ') if save == 'Y' or save == 'y': item = dict() item['category'] = itemCategory item['price'] = itemPrice item['description'] = itemDescription item['weight'] = itemWeightOrVolume item['quantity'] = itemquantity item['creation_time'] = itemCreationTime
inventory[itemNameCode] = item print('.... Record saved successfully, New Added Item Name Code is:' + itemNameCode)
def updateItemLevel(): print('Stock Control - Update Item Level:') print('=========================') itemNameCode = input('Enter Item Name Code: ') updateType = input('Enter Update Type (I for Increase/D for Decrease): ') itemquantity = int(input('Enter quantity: ')) save = input('Save (Y/N): ') if save == 'Y' or save == 'y': old_quantity = inventory[itemNameCode]['quantity']
if updateType == 'D' or updateType == 'd': inventory[itemNameCode]['quantity'] = inventory[itemNameCode]['quantity'] - itemquantity elif updateType == 'I' or updateType == 'i': inventory[itemNameCode]['quantity'] = inventory[itemNameCode]['quantity'] + itemquantity
print('.... Record saved successfully, Item Name Code {}, Old quantity={} and new updated quantity is: {}.'.format(itemNameCode, old_quantity, inventory[itemNameCode]['quantity']))
def removeItem(): print('Stock Control - Remove Item:') print('=========================')
itemNameCode = input('Enter Item Name Code: ') save = input('Save (Y/N): ') if save == 'Y' or save == 'y': inventory.pop(itemNameCode) print('.... Record saved successfully, Item Removed, Item Name Code is:' + itemNameCode)
def listInventory(): print('Stock Control - List Inventory:') print('=========================')
if len(inventory) == 0: print('Inventory is empty') return
for key, value in inventory.items(): print('----------------------------------------------') print('Item Code: ' + key) print('----------------------------------------------') display_item(value) print('----------------------------------------------')
def showItemsQuantity(): print('Stock Control - Show Items whose quantity
for key, value in inventory.items(): if value['quantity']
def showItemsPrice(): print('Stock Control - Show Items above a given price:') print('=========================')
itemPrice = float(input('Enter Price Per Item (QR): '))
for key, value in inventory.items(): if value['price'] > itemPrice: print('----------------------------------------------') print('Item Code: ' + key) print('----------------------------------------------') display_item(value) print('----------------------------------------------')
def showItemsAveragePrice(): print('Stock Control - Show Items above the average price:') print('=========================')
avg_price = 0;
for key, value in inventory.items(): avg_price = avg_price + value['price']
avg_price = avg_price / len(inventory)
for key, value in inventory.items(): if value['price'] > avg_price: print('----------------------------------------------') print('Item Code: ' + key) print('----------------------------------------------') display_item(value) print('----------------------------------------------')
def stockStatistics(): pass
def get_and_execute_choice(): choice = int(input('Enter choice: ')) if choice == 1: addItem() elif choice == 2: updateItemLevel() elif choice == 3: removeItem() elif choice == 4: listInventory() elif choice == 5: showItemsQuantity() elif choice == 6: showItemsPrice() elif choice == 7: showItemsAveragePrice() elif choice == 8: stockStatistics() elif choice == 9: print('. . . Exiting Inventory System, see you again later!') global run run = False else: print('Please enter a choice from 1 to 9')
def main(): while run: display_menu() get_and_execute_choice()
main()
Now need to add these on above coding
Regarding your question, you need to display the value for the below: - the current value of the stock (sum of price*quantity) - the average price of all items in the inventory For the rest, you need to show the item details who achieves the condition: - the most expensive item - the least expensive item - the least stocked item
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started