From 451c324e5d9bae2ea1db31e05ff3e736b30f608e Mon Sep 17 00:00:00 2001 From: "mariiakoval.dr" Date: Tue, 7 Oct 2025 15:15:31 +0200 Subject: [PATCH] lad done --- lab-python-data-structures.ipynb | 75 +++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..505c293d 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,82 @@ "\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": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Inventory:\n", + "t-shirt: 5\n", + "mug: 4\n", + "hat: 8\n", + "book: 73\n", + "keychain: 5\n", + "Customer orders: {'book', 'mug', 'hat'}\n", + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 3.1578947368421053 %\n", + "Inventory apdeted:\n", + "t-shirt: 4\n", + "mug: 3\n", + "hat: 7\n", + "book: 72\n", + "keychain: 4\n" + ] + } + ], + "source": [ + "products = [ \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "for product in products:\n", + " pr_q = int(input(f\"Please enter the quantity of a product avalible: {product}\"))\n", + " inventory[product] = pr_q\n", + "\n", + "print(\"Inventory:\")\n", + "\n", + "for product, pr_q in inventory.items():\n", + " print (f\"{product}: {pr_q}\")\n", + "\n", + "customer_orders = set()\n", + "for _ in range(3):\n", + " while True:\n", + " pr = (input(f\"Please enter the name of the product from the list that you want to order : {products}\"))\n", + " \n", + " if pr in products:\n", + " customer_orders.add(pr)\n", + " break\n", + " else:\n", + " print(\"This product is not available. Please choose from the list.\")\n", + "\n", + "print(f\"Customer orders: {customer_orders}\")\n", + "\n", + "tpo = int(len(customer_orders))\n", + "sum_inv = int(sum(inventory.values()))\n", + "ppo = (tpo/sum_inv)*100\n", + "order_status = (tpo, ppo)\n", + "\n", + "print(\"Order Statistics:\")\n", + "print(f\"Total Products Ordered: {tpo}\")\n", + "print(f\"Percentage of Products Ordered: {ppo} %\")\n", + "\n", + "for key in inventory:\n", + " inventory[key] -=1\n", + " \n", + "print(\"Inventory apdeted:\")\n", + "\n", + "for product, pr_q in inventory.items():\n", + " print (f\"{product}: {pr_q}\")" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +139,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.3" } }, "nbformat": 4,