From a5ed8d123a265749893f4473f0a518d184df6ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Gomes?= Date: Tue, 7 Oct 2025 14:53:17 +0200 Subject: [PATCH 1/2] lab done --- lab-python-data-structures.ipynb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..3891d7d3 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +50,19 @@ "\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": null, + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "i did" + ] } ], "metadata": { From 6c74e10d823eb46a9b97c031f79405d950c2e8c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ant=C3=B3nio=20Gomes?= Date: Tue, 7 Oct 2025 16:30:12 +0200 Subject: [PATCH 2/2] Done with the lab --- lab-python-data-structures.ipynb | 87 ++++++++++++++++++++++++++++---- 1 file changed, 78 insertions(+), 9 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 3891d7d3..3fcc18cc 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,21 +53,90 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 12, 'mug': 2, 'hat': 3, 'book': 4, 'keychain': 5}\n", + "{'hat', 'book', 'mug'}\n", + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0\n", + "('t-shirt', 12)\n", + "('mug', 1)\n", + "('hat', 2)\n", + "('book', 3)\n", + "('keychain', 5)\n" + ] } - }, - "outputs": [], + ], "source": [ - "i did" + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "\n", + "for product in products:\n", + " quantity = int(input(\"Insert Quantity of: \" + product + \"s\"))\n", + " inventory[product] = quantity\n", + " \n", + "print(inventory)\n", + "\n", + "customer_orders = set()\n", + "\n", + "while len(customer_orders) < 3:\n", + " if len(customer_orders) == 0:\n", + " order = input(\"Select the first product out of the products list: \")\n", + " \n", + " if order in products:\n", + " customer_orders.add(order)\n", + " \n", + " else:\n", + " print(\"Invalid product. Please choose one from the list.\")\n", + " \n", + " elif len(customer_orders) == 1:\n", + " order = input(\"Select the second product out of the products list: \")\n", + " \n", + " if order in products:\n", + " customer_orders.add(order)\n", + " \n", + " else:\n", + " print(\"Invalid product. Please choose one from the list.\")\n", + "\n", + " else:\n", + " order = input(\"Select the third and last product out of the products list: \")\n", + "\n", + " if order in products:\n", + " customer_orders.add(order)\n", + " \n", + " else:\n", + " print(\"Invalid product. Please choose one from the list.\")\n", + "\n", + "print(customer_orders)\n", + "\n", + "total_products_ordered = len(customer_orders)\n", + "total_available_prodcuts = len(products)\n", + "percentage_ordered = (total_products_ordered / total_available_prodcuts) * 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 item in customer_orders:\n", + " #inventory.pop(item)\n", + " inventory[item] -= 1\n", + "\n", + "for items in inventory.items():\n", + " print(items)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -81,7 +150,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" } }, "nbformat": 4,