-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinv_man_sys.py
60 lines (51 loc) · 1.86 KB
/
inv_man_sys.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def management_sys():
items = []
def add_item():
name = input("Enter name of the item: ")
quantity = int(input("Enter quantity: "))
price = float(input("Enter price: "))
item = {"name": name, "quantity": quantity, "price": price}
for item in items:
if item["name"].lower()==name.lower():
print("item already exists")
break
else:
items.append(item)
print("item added sucessfully")
def update_item():
name = input("Enter the name of the item to update: ")
for item in items:
if item["name"].lower() == name.lower():
new_quantity = int(input("Enter the new quantity: "))
item["quantity"] = new_quantity
print("quantity updated")
break
else:
print("Item not found!")
def delete_item():
name = input("Enter the name of the item to delete: ")
for item in items:
if item["name"].lower() == name.lower():
items.remove(item)
print("item deleted")
break
else:
print("item not found")
while True:
op = input("Enter the operation to be performed (ADD, UPDATE, DELETE, TOTAL, EXIT): ").upper()
if op == "ADD":
add_item()
elif op=="UPDATE":
update_item()
elif op=="DELETE":
delete_item()
elif op == "TOTAL":
total = sum(item['quantity'] * item['price'] for item in items)
print(f"Total value of items: {total}")
elif op == "EXIT":
print("Exiting the system.")
break
else:
print("Invalid operation. Please try again.")
print(items)
management_sys()