forked from data-bootcamp-v4/lab-python-data-structures
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
50 lines (34 loc) · 1.59 KB
/
main.py
File metadata and controls
50 lines (34 loc) · 1.59 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
41
42
43
44
45
46
47
48
49
50
product = ["t-shirt", "mug", "hat", "book", "keychain"]
inventory = {}
print("\nPlease enter the quantity of the following products :")
for item in product:
quantity = input(f"{item}: ")
inventory[item] = int(quantity)
#Below codes are for the item that user want to buy
customer_orders = set()
print("\nPlease provide us the 3 items that you like to order from our inventory")
while len(customer_orders) < 3:
order = input("Order: ").lower()
if order in product:
customer_orders.add(order)
else:
print("This item is not available")
print(customer_orders)
#Following code will show the ordered item and show the remaining item in percentage
#Total number of ordered list
ordered_list = len(customer_orders)
print(f'\nTotal Product Ordered: {ordered_list}')
#Total products in inventory
total_products = sum(inventory.values()) #used inventory.values to access the values
print(f'\nTotal Products: {total_products}')
percentage = (ordered_list / total_products) * 100 #using the formula to get value in percentage
print(f'\nPercentage of Products ordered: {percentage }%')
#Created an variable to update the list in a tuple
order_status = (ordered_list, percentage)
print(f'\nOrder Statistics: \nTotal Products Ordered: {order_status[0]} \nPercentage of Products Ordered: {order_status[1]}% ')
#Updating the inventory by subtracting 1 from the quantity of each product
for items in customer_orders: #going through the customer order to get the updated inventory
inventory[item] -= 1
print("\nUpdated inventory:")
for item, quantity in inventory.items():
print(f"{item}: {quantity}")