From a4e2ce686d6dcf63bf261eaec10101f2f65a0283 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Maria=20Monteiro?= Date: Fri, 16 Jan 2026 12:30:30 +0000 Subject: [PATCH] Add files via upload --- lab-python-data-structures.ipynb | 103 ++++++++++++++++++++++++++++++- 1 file changed, 101 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..e5ece41b 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,110 @@ "\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": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 10, 'mug': 10, 'hat': 10, 'book': 10, 'keychain': 10}\n", + "{'book', 'hat', 'mug'}\n", + "The number of orders is 3\n", + "The percentage is 60.0 %\n", + "(3, 60.0)\n", + "Order Statistics: \n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60 %\n", + "Updated Inventory :\n", + "Inventory of t-shirts : 10\n", + "Inventory of mugs : 9\n", + "Inventory of hats : 9\n", + "Inventory of books : 9\n", + "Inventory of keychains : 10\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "inventory = {}\n", + "\n", + "for product in products:\n", + " quantity = int(input(\"enter quantity of stock of \"))\n", + " inventory[product] = quantity\n", + "\n", + "print(inventory)\n", + "\n", + "customer_orders = set()\n", + "\n", + "order = input(\"add 3 products to your order\")\n", + "customer_orders.add(order)\n", + "\n", + "order = input(\"add 2 products to your order\")\n", + "customer_orders.add(order)\n", + "\n", + "order = input(\"add 3 products to your order\")\n", + "customer_orders.add(order)\n", + "\n", + "print(customer_orders)\n", + "\n", + "total_orders = len(customer_orders)\n", + "total_products = len(products)\n", + "\n", + "print(\"The number of orders is \", total_orders)\n", + "\n", + "percentage_products = ((total_orders / total_products) * 100)\n", + "\n", + "print(\"The percentage is \", percentage_products,\"%\")\n", + "\n", + "order_status = (total_orders, percentage_products)\n", + "\n", + "print(order_status)\n", + "\n", + "# 8\n", + "\n", + "print(\"Order Statistics: \")\n", + "print(\"Total Products Ordered: \", total_orders)\n", + "print(\"Percentage of Products Ordered: \", int(percentage_products), \"%\")\n", + "\n", + "\n", + "# 9\n", + "\n", + "product_name = customer_orders.pop()\n", + "inventory[product_name] -=1\n", + "\n", + "product_name = customer_orders.pop()\n", + "inventory[product_name] -=1\n", + "\n", + "product_name = customer_orders.pop()\n", + "inventory[product_name] -=1\n", + "\n", + "\n", + "#10\n", + "\n", + "print(\"Updated Inventory :\")\n", + "print(\"Inventory of t-shirts :\", inventory[\"t-shirt\"])\n", + "print(\"Inventory of mugs :\", inventory[\"mug\"])\n", + "print(\"Inventory of hats :\", inventory[\"hat\"])\n", + "print(\"Inventory of books :\", inventory[\"book\"])\n", + "print(\"Inventory of keychains :\", inventory[\"keychain\"])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +167,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4,