From fdbc0201244653f24c90b57808d3c1492aa1aac8 Mon Sep 17 00:00:00 2001 From: Raquel Marques Date: Tue, 15 Sep 2026 13:43:36 +0100 Subject: [PATCH] Raquel changes --- lab-python-data-structures.ipynb | 76 +++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..36b827cd 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,83 @@ "\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': 9, 'mug': 7, 'hat': 8, 'book': 5, 'keychain': 9}\n", + "{'hat', 'mug', 'book'}\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 7.894736842105263\n", + "Inventory Updated:\n", + "t-shirt 9\n", + "mug 6\n", + "hat 7\n", + "book 4\n", + "keychain 9\n" + ] + } + ], + "source": [ + "produtcs = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "inventory = {}\n", + "\n", + "inventory.fromkeys(produtcs)\n", + "x = 0\n", + "\n", + "for produtc in produtcs:\n", + " inventory[produtcs[x]] = int(input(f\"Please, enter the number of {produtcs[x]} available in the inventory:\"))\n", + " x += 1\n", + "\n", + "print(inventory)\n", + "\n", + "\n", + "customers_orders = set()\n", + "\n", + "produtcs_1 = input(\"Please, introduce the product that the costumer wants to order:\")\n", + "produtcs_2 = input(\"Please, introduce the product that the costumer wants to order:\")\n", + "produtcs_3 = input(\"Please, introduce the product that the costumer wants to order:\")\n", + "\n", + "customers_orders = {produtcs_1,produtcs_2,produtcs_3}\n", + "\n", + "print(customers_orders)\n", + "\n", + "\n", + "# Total Products Ordered\n", + "\n", + "print(\"Total Products Ordered:\",len(customers_orders))\n", + "\n", + "# Percentage of Products Ordered\n", + "\n", + "total = inventory['t-shirt'] + inventory['mug'] + inventory['hat'] + inventory['book'] + inventory['keychain']\n", + "\n", + "percentage = (len(customers_orders) * 100) / total\n", + "\n", + "\n", + "print(\"Percentage of Products Ordered:\",percentage)\n", + "\n", + "for order in customers_orders:\n", + " if order in inventory:\n", + " inventory[order] = inventory[order] - 1\n", + "\n", + "# Total Products Ordered\n", + "\n", + "print(\"Inventory Updated:\")\n", + "for prod in inventory:\n", + " print(prod,inventory[prod])" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +140,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.6" } }, "nbformat": 4,