From c494e1b3fe229422dbb4e17d562ef69a899a3936 Mon Sep 17 00:00:00 2001 From: Kevin Gonzalez Date: Mon, 13 Apr 2026 15:44:48 +0200 Subject: [PATCH 1/6] Update lab-python-data-structures.ipynb prueba lab --- lab-python-data-structures.ipynb | 441 ++++++++++++++++++++++++++++++- 1 file changed, 439 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..61b74938 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,448 @@ "\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": {}, + "outputs": [], + "source": [ + "# 1. Crear lista de productos\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 2. Crear un diccionario de inventario\n", + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [], + "source": [ + "# 3 Preguntar al usuario la cantidad de cada producto\n", + "quantity1 = int(input(\"Enter quantity for t-shirt: \"))\n", + "inventory[\"t-shirt\"] = quantity1\n" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "10" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "quantity1" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [], + "source": [ + "quantity2 = int(input(\"Enter quantity for mug: \"))\n", + "inventory[\"mug\"] = quantity2" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "8" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "quantity2" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [], + "source": [ + "quantity3 = int(input(\"Enter quantity for hat: \"))\n", + "inventory[\"hat\"] = quantity3" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "6" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "quantity3" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [], + "source": [ + "quantity4 = int(input(\"Enter quantity for book: \"))\n", + "inventory[\"book\"] = quantity4" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "12" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "quantity4" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [], + "source": [ + "quantity5 = int(input(\"Enter quantity for keychain: \"))\n", + "inventory[\"keychain\"] = quantity5" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "quantity5" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "# 4. Crea un set para almacenar los pedidos de los clientes\n", + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "5# Pregunta al usuario por tres productos \n", + "order1 = input(\"Enter a product to order: \")\n", + "customer_orders.add(order1)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'t-shirt'" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "order1" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [], + "source": [ + "order2 = input(\"Enter a product to order: \")\n", + "customer_orders.add(order2)" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'mug'" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "order2" + ] + }, + { + "cell_type": "code", + "execution_count": 45, + "metadata": {}, + "outputs": [], + "source": [ + "order3 = input(\"Enter a product to order: \")\n", + "customer_orders.add(order3)" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'hat'" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "order3" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Customer Orders: {'t-shirt', '\"t-shirt\"', 'mug', 'hat'}\n" + ] + } + ], + "source": [ + "# 6. Print the customer orders\n", + "print(\"Customer Orders:\", customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders.remove('t-shirt')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Customer Orders: {'\"t-shirt\"', 'mug', 'hat'}\n" + ] + } + ], + "source": [ + "# 6. print the customer orders after removing 't-shirt'\n", + "print(\"Customer Orders:\", customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [], + "source": [ + "# 7. Calcular estadisticas\n", + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = (total_products_ordered / len(products)) * 100" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [], + "source": [ + "order_status = (total_products_ordered, percentage_ordered)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "total_products_ordered" + ] + }, + { + "cell_type": "code", + "execution_count": 59, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "60.0" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "percentage_ordered" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0 %\n" + ] + } + ], + "source": [ + "# 8. Estadisticas\n", + "print(\"\\nOrder Statistics:\")\n", + "print(\"Total Products Ordered:\", order_status[0])\n", + "print(\"Percentage of Products Ordered:\", order_status[1], \"%\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# 9. Actualizar inventario \n", + "for product in inventory:\n", + " inventory[product] -= 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Updated Inventory:\n", + "t-shirt : 9\n", + "mug : 7\n", + "hat : 5\n", + "book : 11\n", + "keychain : 3\n" + ] + } + ], + "source": [ + "# 10. inventario actualizado\n", + "print(\"\\nUpdated Inventory:\")\n", + "for product, quantity in inventory.items():\n", + " print(product, \":\", quantity)" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +505,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4, From f21c0e53704ed383e30aa12e62465d6c7b15fda8 Mon Sep 17 00:00:00 2001 From: Kevin Gonzalez Date: Mon, 13 Apr 2026 15:58:59 +0200 Subject: [PATCH 2/6] Update lab-python-data-structures.ipynb prueba lab 1 --- lab-python-data-structures.ipynb | 53 ++++++++------------------------ 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 61b74938..2cedbecd 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -325,34 +325,7 @@ }, { "cell_type": "code", - "execution_count": 53, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Customer Orders: {'t-shirt', '\"t-shirt\"', 'mug', 'hat'}\n" - ] - } - ], - "source": [ - "# 6. Print the customer orders\n", - "print(\"Customer Orders:\", customer_orders)" - ] - }, - { - "cell_type": "code", - "execution_count": 54, - "metadata": {}, - "outputs": [], - "source": [ - "customer_orders.remove('t-shirt')" - ] - }, - { - "cell_type": "code", - "execution_count": null, + "execution_count": 64, "metadata": {}, "outputs": [ { @@ -364,13 +337,13 @@ } ], "source": [ - "# 6. print the customer orders after removing 't-shirt'\n", + "# 6. Print the customer orders\n", "print(\"Customer Orders:\", customer_orders)" ] }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ @@ -381,7 +354,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 66, "metadata": {}, "outputs": [], "source": [ @@ -390,7 +363,7 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 67, "metadata": {}, "outputs": [ { @@ -399,7 +372,7 @@ "3" ] }, - "execution_count": 58, + "execution_count": 67, "metadata": {}, "output_type": "execute_result" } @@ -410,7 +383,7 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 68, "metadata": {}, "outputs": [ { @@ -419,7 +392,7 @@ "60.0" ] }, - "execution_count": 59, + "execution_count": 68, "metadata": {}, "output_type": "execute_result" } @@ -430,7 +403,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 70, "metadata": {}, "outputs": [ { @@ -440,7 +413,7 @@ "\n", "Order Statistics:\n", "Total Products Ordered: 3\n", - "Percentage of Products Ordered: 60.0 %\n" + "Percentage of Products Ordered: 60.0%\n" ] } ], @@ -448,12 +421,12 @@ "# 8. Estadisticas\n", "print(\"\\nOrder Statistics:\")\n", "print(\"Total Products Ordered:\", order_status[0])\n", - "print(\"Percentage of Products Ordered:\", order_status[1], \"%\")" + "print(f\"Percentage of Products Ordered: {order_status[1]}%\")" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 72, "metadata": {}, "outputs": [], "source": [ @@ -464,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 71, "metadata": {}, "outputs": [ { From 64351ee451840a2f147d5fc9d015f5a73f0b7e92 Mon Sep 17 00:00:00 2001 From: Kevin Gonzalez Date: Mon, 13 Apr 2026 16:07:19 +0200 Subject: [PATCH 3/6] Update lab-python-data-structures.ipynb prueba lab 2 --- lab-python-data-structures.ipynb | 92 +++++++++----------------------- 1 file changed, 26 insertions(+), 66 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 2cedbecd..b600bcc2 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 73, "metadata": {}, "outputs": [], "source": [ @@ -63,7 +63,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 74, "metadata": {}, "outputs": [], "source": [ @@ -73,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 76, "metadata": {}, "outputs": [], "source": [ @@ -84,7 +84,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -104,7 +104,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 77, "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -134,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 78, "metadata": {}, "outputs": [], "source": [ @@ -144,7 +144,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -164,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 79, "metadata": {}, "outputs": [], "source": [ @@ -174,7 +174,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -194,7 +194,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 80, "metadata": {}, "outputs": [], "source": [ @@ -204,7 +204,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -224,7 +224,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -234,7 +234,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -245,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -265,7 +265,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -275,7 +275,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -295,7 +295,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 85, "metadata": {}, "outputs": [], "source": [ @@ -305,7 +305,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 86, "metadata": {}, "outputs": [ { @@ -314,7 +314,7 @@ "'hat'" ] }, - "execution_count": 46, + "execution_count": 86, "metadata": {}, "output_type": "execute_result" } @@ -325,7 +325,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 83, "metadata": {}, "outputs": [ { @@ -343,7 +343,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 87, "metadata": {}, "outputs": [], "source": [ @@ -354,7 +354,7 @@ }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 88, "metadata": {}, "outputs": [], "source": [ @@ -363,47 +363,7 @@ }, { "cell_type": "code", - "execution_count": 67, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "3" - ] - }, - "execution_count": 67, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "total_products_ordered" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "60.0" - ] - }, - "execution_count": 68, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "percentage_ordered" - ] - }, - { - "cell_type": "code", - "execution_count": 70, + "execution_count": 90, "metadata": {}, "outputs": [ { @@ -426,7 +386,7 @@ }, { "cell_type": "code", - "execution_count": 72, + "execution_count": 91, "metadata": {}, "outputs": [], "source": [ @@ -437,7 +397,7 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 92, "metadata": {}, "outputs": [ { From 27b23f5ccb0fc94ce17cb47ef4934e17ada48a19 Mon Sep 17 00:00:00 2001 From: Kevin Gonzalez Date: Mon, 13 Apr 2026 16:26:17 +0200 Subject: [PATCH 4/6] Update lab-python-data-structures.ipynb prueba lab 3 --- lab-python-data-structures.ipynb | 400 ++++--------------------------- 1 file changed, 52 insertions(+), 348 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index b600bcc2..bf28dbb8 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,370 +53,74 @@ }, { "cell_type": "code", - "execution_count": 73, - "metadata": {}, - "outputs": [], - "source": [ - "# 1. Crear lista de productos\n", - "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" - ] - }, - { - "cell_type": "code", - "execution_count": 74, - "metadata": {}, - "outputs": [], - "source": [ - "# 2. Crear un diccionario de inventario\n", - "inventory = {}" - ] - }, - { - "cell_type": "code", - "execution_count": 76, - "metadata": {}, - "outputs": [], - "source": [ - "# 3 Preguntar al usuario la cantidad de cada producto\n", - "quantity1 = int(input(\"Enter quantity for t-shirt: \"))\n", - "inventory[\"t-shirt\"] = quantity1\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "10" - ] - }, - "execution_count": 32, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "quantity1" - ] - }, - { - "cell_type": "code", - "execution_count": 77, - "metadata": {}, - "outputs": [], - "source": [ - "quantity2 = int(input(\"Enter quantity for mug: \"))\n", - "inventory[\"mug\"] = quantity2" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "8" - ] - }, - "execution_count": 31, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "quantity2" - ] - }, - { - "cell_type": "code", - "execution_count": 78, - "metadata": {}, - "outputs": [], - "source": [ - "quantity3 = int(input(\"Enter quantity for hat: \"))\n", - "inventory[\"hat\"] = quantity3" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "6" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "quantity3" - ] - }, - { - "cell_type": "code", - "execution_count": 79, - "metadata": {}, - "outputs": [], - "source": [ - "quantity4 = int(input(\"Enter quantity for book: \"))\n", - "inventory[\"book\"] = quantity4" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "12" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "quantity4" - ] - }, - { - "cell_type": "code", - "execution_count": 80, - "metadata": {}, - "outputs": [], - "source": [ - "quantity5 = int(input(\"Enter quantity for keychain: \"))\n", - "inventory[\"keychain\"] = quantity5" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "4" - ] - }, - "execution_count": 29, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "quantity5" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# 4. Crea un set para almacenar los pedidos de los clientes\n", - "customer_orders = set()" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "5# Pregunta al usuario por tres productos \n", - "order1 = input(\"Enter a product to order: \")\n", - "customer_orders.add(order1)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'t-shirt'" - ] - }, - "execution_count": 39, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "order1" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "order2 = input(\"Enter a product to order: \")\n", - "customer_orders.add(order2)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'mug'" - ] - }, - "execution_count": 37, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "order2" - ] - }, - { - "cell_type": "code", - "execution_count": 85, - "metadata": {}, - "outputs": [], - "source": [ - "order3 = input(\"Enter a product to order: \")\n", - "customer_orders.add(order3)" - ] - }, - { - "cell_type": "code", - "execution_count": 86, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "'hat'" - ] - }, - "execution_count": 86, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "order3" - ] - }, - { - "cell_type": "code", - "execution_count": 83, + "execution_count": 96, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Customer Orders: {'\"t-shirt\"', 'mug', 'hat'}\n" - ] - } - ], - "source": [ - "# 6. Print the customer orders\n", - "print(\"Customer Orders:\", customer_orders)" - ] - }, - { - "cell_type": "code", - "execution_count": 87, - "metadata": {}, - "outputs": [], - "source": [ - "# 7. Calcular estadisticas\n", - "total_products_ordered = len(customer_orders)\n", - "percentage_ordered = (total_products_ordered / len(products)) * 100" - ] - }, - { - "cell_type": "code", - "execution_count": 88, - "metadata": {}, - "outputs": [], - "source": [ - "order_status = (total_products_ordered, percentage_ordered)" - ] - }, - { - "cell_type": "code", - "execution_count": 90, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", + "Customer Orders: {'mug', 't-shirt', 'hat'}\n", "Order Statistics:\n", "Total Products Ordered: 3\n", - "Percentage of Products Ordered: 60.0%\n" - ] - } - ], - "source": [ - "# 8. Estadisticas\n", - "print(\"\\nOrder Statistics:\")\n", - "print(\"Total Products Ordered:\", order_status[0])\n", - "print(f\"Percentage of Products Ordered: {order_status[1]}%\")" - ] - }, - { - "cell_type": "code", - "execution_count": 91, - "metadata": {}, - "outputs": [], - "source": [ - "# 9. Actualizar inventario \n", - "for product in inventory:\n", - " inventory[product] -= 1" - ] - }, - { - "cell_type": "code", - "execution_count": 92, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", + "Percentage of Products Ordered: 60.0%\n", "Updated Inventory:\n", "t-shirt : 9\n", "mug : 7\n", "hat : 5\n", - "book : 11\n", - "keychain : 3\n" + "book : 12\n", + "keychain : 4\n" ] } ], "source": [ - "# 10. inventario actualizado\n", - "print(\"\\nUpdated Inventory:\")\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "inventory = {}\n", + "\n", + "quantity1 = int(input(\"Enter quantity for t-shirt: \"))\n", + "inventory[\"t-shirt\"] = quantity1\n", + "\n", + "quantity2 = int(input(\"Enter quantity for mug: \"))\n", + "inventory[\"mug\"] = quantity2\n", + "\n", + "quantity3 = int(input(\"Enter quantity for hat: \"))\n", + "inventory[\"hat\"] = quantity3\n", + "\n", + "quantity4 = int(input(\"Enter quantity for book: \"))\n", + "inventory[\"book\"] = quantity4\n", + "\n", + "quantity5 = int(input(\"Enter quantity for keychain: \"))\n", + "inventory[\"keychain\"] = quantity5\n", + "\n", + "customer_orders = set()\n", + "\n", + "# Ask the user for three products\n", + "order1 = input(\"Enter a product to order: \")\n", + "customer_orders.add(order1)\n", + "\n", + "order2 = input(\"Enter a product to order: \")\n", + "customer_orders.add(order2)\n", + "\n", + "order3 = input(\"Enter a product to order: \")\n", + "customer_orders.add(order3)\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", + "\n", + "order_status = (total_products_ordered, percentage_ordered)\n", + "\n", + "print(\"Order Statistics:\")\n", + "print(f\"Total Products Ordered: {order_status[0]}\")\n", + "print(f\"Percentage of Products Ordered: {order_status[1]}%\")\n", + "\n", + "for product in customer_orders:\n", + " if product in inventory:\n", + " inventory[product] -= 1\n", + "\n", + "print(\"Updated Inventory:\")\n", "for product, quantity in inventory.items():\n", " print(product, \":\", quantity)" ] From 9b2db78c5d1b7027f0bbfdbef97b5db141693576 Mon Sep 17 00:00:00 2001 From: Kevin Gonzalez Date: Mon, 13 Apr 2026 16:31:50 +0200 Subject: [PATCH 5/6] Update lab-python-data-structures.ipynb prueba lab 4 --- lab-python-data-structures.ipynb | 65 +++++++++++++++----------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index bf28dbb8..b6b0dfe7 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 96, + "execution_count": 97, "metadata": {}, "outputs": [ { @@ -61,68 +61,63 @@ "output_type": "stream", "text": [ "Customer Orders: {'mug', 't-shirt', 'hat'}\n", + "\n", "Order Statistics:\n", "Total Products Ordered: 3\n", "Percentage of Products Ordered: 60.0%\n", + "\n", "Updated Inventory:\n", - "t-shirt : 9\n", - "mug : 7\n", - "hat : 5\n", - "book : 12\n", - "keychain : 4\n" + "t-shirt: 9\n", + "mug: 7\n", + "hat: 5\n", + "book: 11\n", + "keychain: 3\n" ] } ], "source": [ + "# 1. Create a list of products\n", "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", "\n", + "# 2. Create an empty dictionary for inventory\n", "inventory = {}\n", "\n", - "quantity1 = int(input(\"Enter quantity for t-shirt: \"))\n", - "inventory[\"t-shirt\"] = quantity1\n", - "\n", - "quantity2 = int(input(\"Enter quantity for mug: \"))\n", - "inventory[\"mug\"] = quantity2\n", - "\n", - "quantity3 = int(input(\"Enter quantity for hat: \"))\n", - "inventory[\"hat\"] = quantity3\n", - "\n", - "quantity4 = int(input(\"Enter quantity for book: \"))\n", - "inventory[\"book\"] = quantity4\n", - "\n", - "quantity5 = int(input(\"Enter quantity for keychain: \"))\n", - "inventory[\"keychain\"] = quantity5\n", + "# 3. Ask user for quantity of each product (using a loop - mejorado)\n", + "for product in products:\n", + " quantity = int(input(f\"Enter quantity for {product}: \"))\n", + " inventory[product] = quantity\n", "\n", + "# 4. Create an empty set for customer orders\n", "customer_orders = set()\n", "\n", - "# Ask the user for three products\n", - "order1 = input(\"Enter a product to order: \")\n", - "customer_orders.add(order1)\n", - "\n", - "order2 = input(\"Enter a product to order: \")\n", - "customer_orders.add(order2)\n", - "\n", - "order3 = input(\"Enter a product to order: \")\n", - "customer_orders.add(order3)\n", + "# 5. Ask the user for three products\n", + "for i in range(3):\n", + " order = input(\"Enter a product to order: \")\n", + " customer_orders.add(order)\n", "\n", + "# 6. Print customer orders\n", "print(\"Customer Orders:\", customer_orders)\n", "\n", + "# 7. Calculate statistics\n", "total_products_ordered = len(customer_orders)\n", "percentage_ordered = (total_products_ordered / len(products)) * 100\n", "\n", + "# Store in a tuple\n", "order_status = (total_products_ordered, percentage_ordered)\n", "\n", - "print(\"Order Statistics:\")\n", + "# 8. Print statistics (formato mejorado)\n", + "print(\"\\nOrder Statistics:\")\n", "print(f\"Total Products Ordered: {order_status[0]}\")\n", "print(f\"Percentage of Products Ordered: {order_status[1]}%\")\n", "\n", - "for product in customer_orders:\n", - " if product in inventory:\n", - " inventory[product] -= 1\n", + "# 9. Update inventory (segĂșn el enunciado: TODOS los productos)\n", + "for product in inventory:\n", + " inventory[product] -= 1\n", "\n", - "print(\"Updated Inventory:\")\n", + "# 10. Print updated inventory (formato limpio)\n", + "print(\"\\nUpdated Inventory:\")\n", "for product, quantity in inventory.items():\n", - " print(product, \":\", quantity)" + " print(f\"{product}: {quantity}\")" ] } ], From f648fd429d45b1b9760a0b9182c420164a75e4e0 Mon Sep 17 00:00:00 2001 From: Kevin Gonzalez Date: Mon, 13 Apr 2026 16:43:07 +0200 Subject: [PATCH 6/6] Update lab-python-data-structures.ipynb prueba lab 5 --- lab-python-data-structures.ipynb | 36 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index b6b0dfe7..68e6a1ff 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 97, + "execution_count": 98, "metadata": {}, "outputs": [ { @@ -76,45 +76,47 @@ } ], "source": [ - "# 1. Create a list of products\n", "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", "\n", - "# 2. Create an empty dictionary for inventory\n", "inventory = {}\n", "\n", - "# 3. Ask user for quantity of each product (using a loop - mejorado)\n", + "# Input inventory with validation\n", "for product in products:\n", - " quantity = int(input(f\"Enter quantity for {product}: \"))\n", - " inventory[product] = quantity\n", + " while True:\n", + " try:\n", + " quantity = int(input(f\"Enter quantity for {product}: \"))\n", + " inventory[product] = quantity\n", + " break\n", + " except:\n", + " print(\"Please enter a valid number\")\n", "\n", - "# 4. Create an empty set for customer orders\n", "customer_orders = set()\n", "\n", - "# 5. Ask the user for three products\n", + "# Input orders with validation\n", "for i in range(3):\n", - " order = input(\"Enter a product to order: \")\n", - " customer_orders.add(order)\n", + " while True:\n", + " order = input(\"Enter a product to order: \")\n", + " if order in products:\n", + " customer_orders.add(order)\n", + " break\n", + " else:\n", + " print(\"Invalid product, try again\")\n", "\n", - "# 6. Print customer orders\n", "print(\"Customer Orders:\", customer_orders)\n", "\n", - "# 7. Calculate statistics\n", "total_products_ordered = len(customer_orders)\n", "percentage_ordered = (total_products_ordered / len(products)) * 100\n", "\n", - "# Store in a tuple\n", "order_status = (total_products_ordered, percentage_ordered)\n", "\n", - "# 8. Print statistics (formato mejorado)\n", "print(\"\\nOrder Statistics:\")\n", "print(f\"Total Products Ordered: {order_status[0]}\")\n", "print(f\"Percentage of Products Ordered: {order_status[1]}%\")\n", "\n", - "# 9. Update inventory (segĂșn el enunciado: TODOS los productos)\n", - "for product in inventory:\n", + "# Clear inventory update\n", + "for product in products:\n", " inventory[product] -= 1\n", "\n", - "# 10. Print updated inventory (formato limpio)\n", "print(\"\\nUpdated Inventory:\")\n", "for product, quantity in inventory.items():\n", " print(f\"{product}: {quantity}\")"