From cb87a4fc9a87cfec790f5608343fa9d098f1f988 Mon Sep 17 00:00:00 2001 From: fisicangel Date: Fri, 31 Jul 2026 15:01:14 +0200 Subject: [PATCH 1/4] Lab Data Structures Ange --- lab_python_data_structures.ipynb | 169 +++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 lab_python_data_structures.ipynb diff --git a/lab_python_data_structures.ipynb b/lab_python_data_structures.ipynb new file mode 100644 index 00000000..5f23516f --- /dev/null +++ b/lab_python_data_structures.ipynb @@ -0,0 +1,169 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "source": [], + "metadata": { + "id": "W0tbr8MDof2U" + } + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [], + "id": "SoPBalionTrk" + }, + "source": [ + "# Lab | Data Structures" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "_wWoQSPznTro" + }, + "source": [ + "## Exercise: Managing Customer Orders\n", + "\n", + "As part of a business venture, you are starting an online store that sells various products. To ensure smooth operations, you need to develop a program that manages customer orders and inventory.\n", + "\n", + "Follow the steps below to complete the exercise:\n", + "\n", + "1. Define a list called `products` that contains the following items: \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\".\n", + "\n", + "2. Create an empty dictionary called `inventory`.\n", + "\n", + "3. Ask the user to input the quantity of each product available in the inventory. Use the product names from the `products` list as keys in the `inventory` dictionary and assign the respective quantities as values.\n", + "\n", + "4. Create an empty set called `customer_orders`.\n", + "\n", + "5. Ask the user to input the name of three products that a customer wants to order (from those in the products list, meaning three products out of \"t-shirt\", \"mug\", \"hat\", \"book\" or \"keychain\". Add each product name to the `customer_orders` set.\n", + "\n", + "6. Print the products in the `customer_orders` set.\n", + "\n", + "7. Calculate the following order statistics:\n", + " - Total Products Ordered: The total number of products in the `customer_orders` set.\n", + " - Percentage of Products Ordered: The percentage of products ordered compared to the total available products.\n", + " \n", + " Store these statistics in a tuple called `order_status`.\n", + "\n", + "8. Print the order statistics using the following format:\n", + " ```\n", + " Order Statistics:\n", + " Total Products Ordered: \n", + " Percentage of Products Ordered: %\n", + " ```\n", + "\n", + "9. Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", + "\n", + "10. Print the updated inventory, displaying the quantity of each product on separate lines.\n", + "\n", + "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations." + ] + }, + { + "cell_type": "markdown", + "source": [ + "**SOLUCION**" + ], + "metadata": { + "id": "Qez3P4nMrjDV" + } + }, + { + "cell_type": "code", + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "\n", + "for product in products:\n", + " qty = int(input(f\"Enter quantity for {product}: \"))\n", + " inventory[product] = qty\n", + "\n", + "customer_orders = set()\n", + "for i in range(3):\n", + " order = input(f\"Enter product #{i+1} to order: \").strip()\n", + " if order in products:\n", + " customer_orders.add(order)\n", + " else:\n", + " print(f\"{order} is not a valid product.\")\n", + "\n", + "print(\"Customer orders:\", customer_orders)\n", + "\n", + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = (total_products_ordered / len(products)) * 100\n", + "order_status = (total_products_ordered, percentage_ordered)\n", + "\n", + "print(\"Order Statistics:\")\n", + "print(\"Total Products Ordered:\", order_status[0])\n", + "print(f\"Percentage of Products Ordered: {order_status[1]:.2f}%\")\n", + "\n", + "for product in inventory:\n", + " inventory[product] -= 1\n", + "\n", + "print(\"Updated inventory:\")\n", + "for product, qty in inventory.items():\n", + " print(f\"{product}: {qty}\")" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "oQfA6mmOrpTw", + "outputId": "3e2422ec-0dbb-4e8a-a876-2c0155852068" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter quantity for t-shirt: 5\n", + "Enter quantity for mug: 6\n", + "Enter quantity for hat: 7\n", + "Enter quantity for book: 8\n", + "Enter quantity for keychain: 9\n", + "Enter product #1 to order: 1\n", + "1 is not a valid product.\n", + "Enter product #2 to order: hat\n", + "Enter product #3 to order: mug\n", + "Customer orders: {'hat', 'mug'}\n", + "Order Statistics:\n", + "Total Products Ordered: 2\n", + "Percentage of Products Ordered: 40.00%\n", + "Updated inventory:\n", + "t-shirt: 4\n", + "mug: 5\n", + "hat: 6\n", + "book: 7\n", + "keychain: 8\n" + ] + } + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + }, + "colab": { + "provenance": [] + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file From 18489e2ef607c082263e74057563b847cbd7f932 Mon Sep 17 00:00:00 2001 From: fisicangel Date: Fri, 31 Jul 2026 17:59:07 +0200 Subject: [PATCH 2/4] Reviewed --- lab_python_data_structures.ipynb | 59 +++++++++++++++++++------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/lab_python_data_structures.ipynb b/lab_python_data_structures.ipynb index 5f23516f..7e6828df 100644 --- a/lab_python_data_structures.ipynb +++ b/lab_python_data_structures.ipynb @@ -1,5 +1,15 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, { "cell_type": "markdown", "source": [], @@ -77,8 +87,8 @@ "inventory = {}\n", "\n", "for product in products:\n", - " qty = int(input(f\"Enter quantity for {product}: \"))\n", - " inventory[product] = qty\n", + " quantity = int(input(f\"Enter quantity for {product}: \"))\n", + " inventory[product] = quantity\n", "\n", "customer_orders = set()\n", "for i in range(3):\n", @@ -88,7 +98,7 @@ " else:\n", " print(f\"{order} is not a valid product.\")\n", "\n", - "print(\"Customer orders:\", customer_orders)\n", + "print(customer_orders)\n", "\n", "total_products_ordered = len(customer_orders)\n", "percentage_ordered = (total_products_ordered / len(products)) * 100\n", @@ -96,47 +106,47 @@ "\n", "print(\"Order Statistics:\")\n", "print(\"Total Products Ordered:\", order_status[0])\n", - "print(f\"Percentage of Products Ordered: {order_status[1]:.2f}%\")\n", + "print(f\"Percentage of Products Ordered: {order_status[1]:.0f}%\")\n", "\n", "for product in inventory:\n", " inventory[product] -= 1\n", "\n", "print(\"Updated inventory:\")\n", - "for product, qty in inventory.items():\n", - " print(f\"{product}: {qty}\")" + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\")" ], "metadata": { + "id": "oQfA6mmOrpTw", "colab": { "base_uri": "https://localhost:8080/" }, - "id": "oQfA6mmOrpTw", - "outputId": "3e2422ec-0dbb-4e8a-a876-2c0155852068" + "outputId": "5a625d32-e94a-4eef-c065-40fafccd139f" }, - "execution_count": null, + "execution_count": 4, "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "Enter quantity for t-shirt: 5\n", - "Enter quantity for mug: 6\n", - "Enter quantity for hat: 7\n", - "Enter quantity for book: 8\n", - "Enter quantity for keychain: 9\n", - "Enter product #1 to order: 1\n", - "1 is not a valid product.\n", - "Enter product #2 to order: hat\n", - "Enter product #3 to order: mug\n", - "Customer orders: {'hat', 'mug'}\n", + "Enter quantity for mug: 4\n", + "Enter quantity for hat: 6\n", + "Enter quantity for book: 7\n", + "Enter quantity for keychain: 7\n", + "Enter product #1 to order: 8\n", + "8 is not a valid product.\n", + "Enter product #2 to order: mug\n", + "Enter product #3 to order: hat\n", + "{'mug', 'hat'}\n", "Order Statistics:\n", "Total Products Ordered: 2\n", - "Percentage of Products Ordered: 40.00%\n", + "Percentage of Products Ordered: 40%\n", "Updated inventory:\n", "t-shirt: 4\n", - "mug: 5\n", - "hat: 6\n", - "book: 7\n", - "keychain: 8\n" + "mug: 3\n", + "hat: 5\n", + "book: 6\n", + "keychain: 6\n" ] } ] @@ -161,7 +171,8 @@ "version": "3.9.13" }, "colab": { - "provenance": [] + "provenance": [], + "include_colab_link": true } }, "nbformat": 4, From eb62b9a6d5bec4d0cfeae542dac125eb82035e0e Mon Sep 17 00:00:00 2001 From: fisicangel Date: Fri, 31 Jul 2026 18:01:19 +0200 Subject: [PATCH 3/4] Delete lab_python_data_structures.ipynb --- lab_python_data_structures.ipynb | 180 ------------------------------- 1 file changed, 180 deletions(-) delete mode 100644 lab_python_data_structures.ipynb diff --git a/lab_python_data_structures.ipynb b/lab_python_data_structures.ipynb deleted file mode 100644 index 7e6828df..00000000 --- a/lab_python_data_structures.ipynb +++ /dev/null @@ -1,180 +0,0 @@ -{ - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "source": [], - "metadata": { - "id": "W0tbr8MDof2U" - } - }, - { - "cell_type": "markdown", - "metadata": { - "tags": [], - "id": "SoPBalionTrk" - }, - "source": [ - "# Lab | Data Structures" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "_wWoQSPznTro" - }, - "source": [ - "## Exercise: Managing Customer Orders\n", - "\n", - "As part of a business venture, you are starting an online store that sells various products. To ensure smooth operations, you need to develop a program that manages customer orders and inventory.\n", - "\n", - "Follow the steps below to complete the exercise:\n", - "\n", - "1. Define a list called `products` that contains the following items: \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\".\n", - "\n", - "2. Create an empty dictionary called `inventory`.\n", - "\n", - "3. Ask the user to input the quantity of each product available in the inventory. Use the product names from the `products` list as keys in the `inventory` dictionary and assign the respective quantities as values.\n", - "\n", - "4. Create an empty set called `customer_orders`.\n", - "\n", - "5. Ask the user to input the name of three products that a customer wants to order (from those in the products list, meaning three products out of \"t-shirt\", \"mug\", \"hat\", \"book\" or \"keychain\". Add each product name to the `customer_orders` set.\n", - "\n", - "6. Print the products in the `customer_orders` set.\n", - "\n", - "7. Calculate the following order statistics:\n", - " - Total Products Ordered: The total number of products in the `customer_orders` set.\n", - " - Percentage of Products Ordered: The percentage of products ordered compared to the total available products.\n", - " \n", - " Store these statistics in a tuple called `order_status`.\n", - "\n", - "8. Print the order statistics using the following format:\n", - " ```\n", - " Order Statistics:\n", - " Total Products Ordered: \n", - " Percentage of Products Ordered: %\n", - " ```\n", - "\n", - "9. Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", - "\n", - "10. Print the updated inventory, displaying the quantity of each product on separate lines.\n", - "\n", - "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations." - ] - }, - { - "cell_type": "markdown", - "source": [ - "**SOLUCION**" - ], - "metadata": { - "id": "Qez3P4nMrjDV" - } - }, - { - "cell_type": "code", - "source": [ - "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", - "inventory = {}\n", - "\n", - "for product in products:\n", - " quantity = int(input(f\"Enter quantity for {product}: \"))\n", - " inventory[product] = quantity\n", - "\n", - "customer_orders = set()\n", - "for i in range(3):\n", - " order = input(f\"Enter product #{i+1} to order: \").strip()\n", - " if order in products:\n", - " customer_orders.add(order)\n", - " else:\n", - " print(f\"{order} is not a valid product.\")\n", - "\n", - "print(customer_orders)\n", - "\n", - "total_products_ordered = len(customer_orders)\n", - "percentage_ordered = (total_products_ordered / len(products)) * 100\n", - "order_status = (total_products_ordered, percentage_ordered)\n", - "\n", - "print(\"Order Statistics:\")\n", - "print(\"Total Products Ordered:\", order_status[0])\n", - "print(f\"Percentage of Products Ordered: {order_status[1]:.0f}%\")\n", - "\n", - "for product in inventory:\n", - " inventory[product] -= 1\n", - "\n", - "print(\"Updated inventory:\")\n", - "for product, quantity in inventory.items():\n", - " print(f\"{product}: {quantity}\")" - ], - "metadata": { - "id": "oQfA6mmOrpTw", - "colab": { - "base_uri": "https://localhost:8080/" - }, - "outputId": "5a625d32-e94a-4eef-c065-40fafccd139f" - }, - "execution_count": 4, - "outputs": [ - { - "output_type": "stream", - "name": "stdout", - "text": [ - "Enter quantity for t-shirt: 5\n", - "Enter quantity for mug: 4\n", - "Enter quantity for hat: 6\n", - "Enter quantity for book: 7\n", - "Enter quantity for keychain: 7\n", - "Enter product #1 to order: 8\n", - "8 is not a valid product.\n", - "Enter product #2 to order: mug\n", - "Enter product #3 to order: hat\n", - "{'mug', 'hat'}\n", - "Order Statistics:\n", - "Total Products Ordered: 2\n", - "Percentage of Products Ordered: 40%\n", - "Updated inventory:\n", - "t-shirt: 4\n", - "mug: 3\n", - "hat: 5\n", - "book: 6\n", - "keychain: 6\n" - ] - } - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.13" - }, - "colab": { - "provenance": [], - "include_colab_link": true - } - }, - "nbformat": 4, - "nbformat_minor": 0 -} \ No newline at end of file From 9206a6581549213d7aca006a675a9b036efb6361 Mon Sep 17 00:00:00 2001 From: fisicangel Date: Fri, 31 Jul 2026 18:02:15 +0200 Subject: [PATCH 4/4] Reviewed --- lab-python-data-structures.ipynb | 252 ++++++++++++++++++++++--------- 1 file changed, 178 insertions(+), 74 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..5051b144 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -1,76 +1,180 @@ { - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "tags": [] - }, - "source": [ - "# Lab | Data Structures " - ] + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [], + "metadata": { + "id": "W0tbr8MDof2U" + } + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [], + "id": "SoPBalionTrk" + }, + "source": [ + "# Lab | Data Structures" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "_wWoQSPznTro" + }, + "source": [ + "## Exercise: Managing Customer Orders\n", + "\n", + "As part of a business venture, you are starting an online store that sells various products. To ensure smooth operations, you need to develop a program that manages customer orders and inventory.\n", + "\n", + "Follow the steps below to complete the exercise:\n", + "\n", + "1. Define a list called `products` that contains the following items: \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\".\n", + "\n", + "2. Create an empty dictionary called `inventory`.\n", + "\n", + "3. Ask the user to input the quantity of each product available in the inventory. Use the product names from the `products` list as keys in the `inventory` dictionary and assign the respective quantities as values.\n", + "\n", + "4. Create an empty set called `customer_orders`.\n", + "\n", + "5. Ask the user to input the name of three products that a customer wants to order (from those in the products list, meaning three products out of \"t-shirt\", \"mug\", \"hat\", \"book\" or \"keychain\". Add each product name to the `customer_orders` set.\n", + "\n", + "6. Print the products in the `customer_orders` set.\n", + "\n", + "7. Calculate the following order statistics:\n", + " - Total Products Ordered: The total number of products in the `customer_orders` set.\n", + " - Percentage of Products Ordered: The percentage of products ordered compared to the total available products.\n", + " \n", + " Store these statistics in a tuple called `order_status`.\n", + "\n", + "8. Print the order statistics using the following format:\n", + " ```\n", + " Order Statistics:\n", + " Total Products Ordered: \n", + " Percentage of Products Ordered: %\n", + " ```\n", + "\n", + "9. Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", + "\n", + "10. Print the updated inventory, displaying the quantity of each product on separate lines.\n", + "\n", + "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations." + ] + }, + { + "cell_type": "markdown", + "source": [ + "**SOLUCION**" + ], + "metadata": { + "id": "Qez3P4nMrjDV" + } + }, + { + "cell_type": "code", + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "\n", + "for product in products:\n", + " quantity = int(input(f\"Enter quantity for {product}: \"))\n", + " inventory[product] = quantity\n", + "\n", + "customer_orders = set()\n", + "for i in range(3):\n", + " order = input(f\"Enter product #{i+1} to order: \").strip()\n", + " if order in products:\n", + " customer_orders.add(order)\n", + " else:\n", + " print(f\"{order} is not a valid product.\")\n", + "\n", + "print(customer_orders)\n", + "\n", + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = (total_products_ordered / len(products)) * 100\n", + "order_status = (total_products_ordered, percentage_ordered)\n", + "\n", + "print(\"Order Statistics:\")\n", + "print(\"Total Products Ordered:\", order_status[0])\n", + "print(f\"Percentage of Products Ordered: {order_status[1]:.0f}%\")\n", + "\n", + "for product in inventory:\n", + " inventory[product] -= 1\n", + "\n", + "print(\"Updated inventory:\")\n", + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\")" + ], + "metadata": { + "id": "oQfA6mmOrpTw", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "outputId": "5a625d32-e94a-4eef-c065-40fafccd139f" + }, + "execution_count": 4, + "outputs": [ + { + "output_type": "stream", + "name": "stdout", + "text": [ + "Enter quantity for t-shirt: 5\n", + "Enter quantity for mug: 4\n", + "Enter quantity for hat: 6\n", + "Enter quantity for book: 7\n", + "Enter quantity for keychain: 7\n", + "Enter product #1 to order: 8\n", + "8 is not a valid product.\n", + "Enter product #2 to order: mug\n", + "Enter product #3 to order: hat\n", + "{'mug', 'hat'}\n", + "Order Statistics:\n", + "Total Products Ordered: 2\n", + "Percentage of Products Ordered: 40%\n", + "Updated inventory:\n", + "t-shirt: 4\n", + "mug: 3\n", + "hat: 5\n", + "book: 6\n", + "keychain: 6\n" + ] + } + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + }, + "colab": { + "provenance": [], + "include_colab_link": true + } }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Exercise: Managing Customer Orders\n", - "\n", - "As part of a business venture, you are starting an online store that sells various products. To ensure smooth operations, you need to develop a program that manages customer orders and inventory.\n", - "\n", - "Follow the steps below to complete the exercise:\n", - "\n", - "1. Define a list called `products` that contains the following items: \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\".\n", - "\n", - "2. Create an empty dictionary called `inventory`.\n", - "\n", - "3. Ask the user to input the quantity of each product available in the inventory. Use the product names from the `products` list as keys in the `inventory` dictionary and assign the respective quantities as values.\n", - "\n", - "4. Create an empty set called `customer_orders`.\n", - "\n", - "5. Ask the user to input the name of three products that a customer wants to order (from those in the products list, meaning three products out of \"t-shirt\", \"mug\", \"hat\", \"book\" or \"keychain\". Add each product name to the `customer_orders` set.\n", - "\n", - "6. Print the products in the `customer_orders` set.\n", - "\n", - "7. Calculate the following order statistics:\n", - " - Total Products Ordered: The total number of products in the `customer_orders` set.\n", - " - Percentage of Products Ordered: The percentage of products ordered compared to the total available products.\n", - " \n", - " Store these statistics in a tuple called `order_status`.\n", - "\n", - "8. Print the order statistics using the following format:\n", - " ```\n", - " Order Statistics:\n", - " Total Products Ordered: \n", - " Percentage of Products Ordered: % \n", - " ```\n", - "\n", - "9. Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", - "\n", - "10. Print the updated inventory, displaying the quantity of each product on separate lines.\n", - "\n", - "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3 (ipykernel)", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.9.13" - } - }, - "nbformat": 4, - "nbformat_minor": 4 -} + "nbformat": 4, + "nbformat_minor": 0 +} \ No newline at end of file