diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..2ce487b1 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +50,92 @@ "\n", "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter the quantity for t-shirt: 5\n", + "Enter the quantity for mug: 6\n", + "Enter the quantity for hat: 9\n", + "Enter the quantity for book: 8\n", + "Enter the quantity for keychain: 4\n", + "Enter a product name: mug\n", + "Enter a product name: hat\n", + "Enter a product name: t-shirt\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Order: {'t-shirt', 'hat', 'mug'}\n", + "Order Statistics: 5\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0 %\n", + "Updated Inventory:\n", + "t-shirt: 4\n", + "mug: 5\n", + "hat: 8\n", + "book: 8\n", + "keychain: 4\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "for product in products:\n", + " quantity = int(input(\"Enter the quantity for \" + product + \": \"))\n", + " inventory[product] = quantity\n", + "\n", + "customer_orders = set()\n", + "\n", + "while len(customer_orders) < 3:\n", + " product_name = input(\"Enter a product name: \")\n", + " if product_name in products:\n", + " customer_orders.add(product_name)\n", + " else:\n", + " print(\"Not in inventory\")\n", + "\n", + "print(\"Order: \", customer_orders)\n", + "\n", + "Total_Products_Ordered = len(customer_orders)\n", + "Total_Products = len(products)\n", + "Percentage_of_products_ordered = (Total_Products_Ordered/Total_Products)*100\n", + "\n", + "print(\"Order Statistics: \", Total_Products)\n", + "print(\"Total Products Ordered: \", Total_Products_Ordered)\n", + "print(\"Percentage of Products Ordered: \", Percentage_of_products_ordered, \"%\")\n", + "\n", + "for product in customer_orders:\n", + " if product in inventory and inventory[product] > 0:\n", + " inventory[product] = inventory[product] - 1\n", + "\n", + "print(\"Updated Inventory:\")\n", + "for product in inventory:\n", + " print(product + \": \" + str(inventory[product]))\n", + "\n", + "\n", + "\n", + " \n", + "\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -68,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.7" } }, "nbformat": 4,