-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject.py
More file actions
40 lines (30 loc) · 1.12 KB
/
Copy pathproject.py
File metadata and controls
40 lines (30 loc) · 1.12 KB
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
item_names = ["Apple", "Bread", "Milk", "Eggs"]
item_prices = [1.0, 2.50, 3.00, 4.50]
item_stock = [100, 20, 50, 4]
while True :
print("task")
selectt = input()
def checkinv(name,price,stock):
for i in range(len(name)):
print(f"name: {name[i]} | price: {price[i]} | stock: {stock[i]}")
print("----------------------------------------")
if selectt == "inventory" :
checkinv(item_names,item_prices,item_stock)
def purchase(product ,qty):
index = -1
for i in range(len(item_names)) :
if product == item_names[i] :
index = i
if item_stock[index] < qty :
print("insufficient stock")
else :
print(f"purchase of {qty} {product}")
print(f"your total amount is {qty*item_prices[index]}")
item_stock[index] = item_stock[index] - qty
if selectt == "purchase" :
print("Product Name:")
product = input()
print("Quantity")
qty = int(input())
purchase(product,qty)
checkinv(item_names,item_prices,item_stock)