Question: M 6 Lab Instructions Introduction: Assignment evaluate student understanding of concepts learned in this module in addition to concepts learned in previous modules. Instructions: In

M6Lab Instructions
Introduction:
Assignment evaluate student understanding of concepts learned in this module in addition to concepts learned in previous modules.
Instructions:
In this assignment, we will be building on M4Pro, remember M4Pro was a store inventor
The program should continue to work the same only in this assignment , we also want to write the information into files.
def category(inventory):
""
Parameters
----------
inventory : nested dictionary for store inventory
function searches for category entered and displays items under category found
"""
category = input("Enter category(first letter of each word MUST be capitalized): ")
if category in inventory: # found
for cat, v in inventory.items():
if cat == category:
print(f'
{"Item":<25}{"Quantity":<15}{"Unit Price"}')
for sub , content in v.items():
print(f'{sub:<25}{content["Quantity"]:<15}${content["Unit Price"]}')
else:
# not found
print(f'
The {category} entered was NOT found!')
def get_item(inventory):
"""
Parameters
----------
inventory : nested dictionary for store inventory
function searches for item entered and displays item information
"""
item = input("Enter Item(first letter MUST be capitalized): ")
# search in nested dict
item_info ='' # placeholder for cat dictionary
for cat, v in inventory.items():
if item in v: # get nested dict
for sub, content in v.items():
if item == sub:
item_info = content
if item_info =='': # item not found so no item category dictionary captured
print(f'
The {item} entered was NOT found!')
else:
print(f'
{"Item":<25}{"Quantity":<15}{"Unit Price"}')
print(f'{item:<25}{item_info["Quantity"]:<15}${item_info["Unit Price"]}')
def update(inventory, item):
"""
Parameters
----------
inventory : nested dictionary for store inventory
function updates quantity , unit price or both
"""
for cat, v in inventory.items():
if item in v: # if found
#ask what they want to update
update = int(input("What would you like to update?
1)Quantity
2)Price
3)Both
"))
if update ==1: #quantity
qnt = int(input("Enter new Quantity: "))
for sub , content in v.items():
if sub == item:
content["Quantity"]=qnt
print("
Quantity updated")
elif update ==2: # Price
price = float(input("Enter new Price $"))
for sub , content in v.items():
if sub == item:
content["Unit Price"]=price
print("
Unit Price updated")
elif update ==3:
qnt = int(input("Enter new Quantity: "))
price = float(input("Enter new Price $"))
for sub , content in v.items():
if sub == item:
content["Quantity"]=qnt
content["Unit Price"]=price
print("
Quantity and Unit Price have been updated")
else:
print("
Invalid value entered!!")
def main():
while True:
print("
--------------------------- Menu ---------------------------")
print("1) Display Inventory Content")
print("2) Category Lookup")
print("3) Item Lookup")
print("4) Update Item Info")
print("5) Exit")
print("------------------------------------------------------------
")
choice = input("Enter your choice: ")
if choice =='1':
display_inventory(inventory)
elif choice =='2':
category_lookup(inventory)
elif choice =='3':
item_lookup(inventory)
elif choice =='4':
update_item_info(inventory)
elif choice =='5':
break
else:
print("Invalid choice. Please try again.")
if __name__=="__main__":
main()
How it should work:
if the user chooses "1", the program is still to display the inventory content but it should ALSO write the information into a CSV file. The file should be called "inventory".
if the user chooses "2", the program is to ask for the category . After the category is entered, the program is to do the following
- Remember the first letter of each word of the category name is capitalized, for instance "Desk Supplies" . Therefore when obtaining the category name from the user, make sure it's converted to the same case.
- if the category is not found , notify the user (this is done already in attached program)
- If the category is found , in addition to what the program displays ADD Total price for each item (quantity * unit price). ALSO write the info into a CSV file. A few important points to - If the c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!