From 8b0afa95377ce534cd8d16474feccc5a9385fcf4 Mon Sep 17 00:00:00 2001 From: Akash Date: Sun, 8 Mar 2026 12:01:10 +0100 Subject: [PATCH] Lab Solved --- lab-python-flow-control.ipynb | 45 +++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..92662dc 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -10,6 +10,51 @@ "# Lab | Flow Control" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"keychain\", \"book\"]\n", + "\n", + "inventory = {}\n", + "\n", + "for product in products:\n", + " quantity = int(input(f\"Enter the quantity available for {product}: \"))\n", + " inventory[product] = quantity\n", + "\n", + " customer_orders = set() \n", + "\n", + "# Keep adding products\n", + " while True :\n", + " product = input(\"Enter a product to order : \")\n", + " customer_orders.add(product)\n", + "\n", + " more_product = input(\"Do you want to add more products? (yes/no) :\")\n", + " if more_product.lower() == \"no\" :\n", + " break\n", + " print(\"Customer Orders : \",customer_orders)\n", + "\n", + " # Order Statistics\n", + "\n", + " total_products_ordered = len(customer_orders)\n", + " percentage_ordered = (total_products_ordered / len(products)) * 100\n", + "\n", + " order_status = (total_products_ordered, percentage_ordered)\n", + "\n", + " print(\"Order Statistics:\")\n", + " print(\"Total Products Ordered:\", total_products_ordered)\n", + " print(\"Percentage of Products Ordered:\", percentage_ordered, \"%\")\n", + "\n", + " for product in customer_orders :\n", + " inventory[product] -= 1\n", + "\n", + " print(\"Updated Inventory : \") \n", + " for product,quantity in inventory.items():\n", + " print(product \":\" quantity) " + ] + }, { "cell_type": "markdown", "id": "3851fcd1-cf98-4653-9c89-e003b7ec9400",