From 26b835c9c26a99790dd1a1c471254a4d981c745c Mon Sep 17 00:00:00 2001 From: Juan Boberg Aguirre Date: Mon, 13 Apr 2026 15:39:39 +0200 Subject: [PATCH 1/4] Update lab-python-data-structures.ipynb --- lab-python-data-structures.ipynb | 100 ++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..e7e26f27 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,107 @@ "\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": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Productos pedidos:\n", + "mug\n", + "t-shirt\n", + "hat\n", + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.00%\n", + "Inventario actualizado:\n", + "t-shirt: 5\n", + "mug: 5\n", + "hat: 7\n", + "book: 15\n", + "keychain: 22\n" + ] + } + ], + "source": [ + "# Paso 1: Definir la lista de productos\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "# Paso 2: Crear un diccionario vacío llamado inventory\n", + "inventory = {}\n", + "\n", + "# Paso 3: Pedir la cantidad de cada producto al usuario\n", + "\n", + "\n", + "cantidad_tshirt = int(input(\"¿Cuánt@s t-shirt hay en inventario? \"))\n", + "cantidad_mug = int(input(\"¿Cuánt@s mug hay en inventario? \"))\n", + "cantidad_hat = int(input(\"¿Cuánt@s hat hay en inventario? \"))\n", + "cantidad_book = int(input(\"¿Cuánt@s book hay en inventario? \"))\n", + "cantidad_keychain = int(input(\"¿Cuánt@s keychain hay en inventario? \"))\n", + "\n", + "inventory[\"t-shirt\"] = cantidad_tshirt\n", + "inventory[\"mug\"] = cantidad_mug\n", + "inventory[\"hat\"] = cantidad_hat\n", + "inventory[\"book\"] = cantidad_book\n", + "inventory[\"keychain\"] = cantidad_keychain\n", + "\n", + "# Paso 4: Crear un conjunto vacío llamado customer_orders\n", + "customer_orders = set()\n", + "\n", + "# Paso 5: Pedir 3 productos al cliente \n", + "producto1 = input(\"Introduce el primer producto que desea pedir: \")\n", + "producto2 = input(\"Introduce el segundo producto que desea pedir: \")\n", + "producto3 = input(\"Introduce el tercer producto que desea pedir: \")\n", + "\n", + "customer_orders.add(producto1)\n", + "customer_orders.add(producto2)\n", + "customer_orders.add(producto3)\n", + "\n", + "# Paso 6: Imprimir los productos del conjunto customer_orders\n", + "print(\"Productos pedidos:\")\n", + "for producto in customer_orders:\n", + " print(producto)\n", + "\n", + "# Paso 7: Calcular las estadísticas del pedido\n", + "total_products_ordered = len(customer_orders) # Total de productos pedidos\n", + "total_available_products = len(products) # Total de productos disponibles\n", + "percentage_ordered = (total_products_ordered / total_available_products) * 100\n", + "order_status = (total_products_ordered, percentage_ordered) # Tupla con las estadísticas\n", + "\n", + "# Paso 8: Imprimir las estadísticas\n", + "print(\"Order Statistics:\")\n", + "print(f\"Total Products Ordered: {order_status[0]}\")\n", + "print(f\"Percentage of Products Ordered: {order_status[1]:.2f}%\")\n", + "\n", + "# Paso 9: Actualizar el inventario restando 1 a cada producto pedido\n", + "if \"t-shirt\" in customer_orders:\n", + " inventory[\"t-shirt\"] -= 1\n", + "if \"mug\" in customer_orders:\n", + " inventory[\"mug\"] -= 1\n", + "if \"hat\" in customer_orders:\n", + " inventory[\"hat\"] -= 1\n", + "if \"book\" in customer_orders:\n", + " inventory[\"book\"] -= 1\n", + "if \"keychain\" in customer_orders:\n", + " inventory[\"keychain\"] -= 1\n", + "\n", + "# Paso 10: Imprimir el inventario actualizado\n", + "print(\"Inventario actualizado:\")\n", + "print(\"t-shirt:\", inventory[\"t-shirt\"])\n", + "print(\"mug:\", inventory[\"mug\"])\n", + "print(\"hat:\", inventory[\"hat\"])\n", + "print(\"book:\", inventory[\"book\"])\n", + "print(\"keychain:\", inventory[\"keychain\"])" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -68,7 +164,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.4" } }, "nbformat": 4, From 3d0c09100a6bad994a34cefcbbc5fe66a9e83d2d Mon Sep 17 00:00:00 2001 From: Juan Boberg Aguirre Date: Mon, 13 Apr 2026 15:43:09 +0200 Subject: [PATCH 2/4] Update lab-python-data-structures.ipynb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolución de los primeros 6 ejercicios --- lab-python-data-structures.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index e7e26f27..33c4fb47 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [ { From af17bd98f668f6fb1d007a5d5f7a1bb06ae7203c Mon Sep 17 00:00:00 2001 From: Juan Boberg Aguirre Date: Mon, 13 Apr 2026 15:52:53 +0200 Subject: [PATCH 3/4] Update lab-python-data-structures.ipynb --- lab-python-data-structures.ipynb | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 33c4fb47..75f70a04 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -119,32 +119,7 @@ "total_products_ordered = len(customer_orders) # Total de productos pedidos\n", "total_available_products = len(products) # Total de productos disponibles\n", "percentage_ordered = (total_products_ordered / total_available_products) * 100\n", - "order_status = (total_products_ordered, percentage_ordered) # Tupla con las estadísticas\n", - "\n", - "# Paso 8: Imprimir las estadísticas\n", - "print(\"Order Statistics:\")\n", - "print(f\"Total Products Ordered: {order_status[0]}\")\n", - "print(f\"Percentage of Products Ordered: {order_status[1]:.2f}%\")\n", - "\n", - "# Paso 9: Actualizar el inventario restando 1 a cada producto pedido\n", - "if \"t-shirt\" in customer_orders:\n", - " inventory[\"t-shirt\"] -= 1\n", - "if \"mug\" in customer_orders:\n", - " inventory[\"mug\"] -= 1\n", - "if \"hat\" in customer_orders:\n", - " inventory[\"hat\"] -= 1\n", - "if \"book\" in customer_orders:\n", - " inventory[\"book\"] -= 1\n", - "if \"keychain\" in customer_orders:\n", - " inventory[\"keychain\"] -= 1\n", - "\n", - "# Paso 10: Imprimir el inventario actualizado\n", - "print(\"Inventario actualizado:\")\n", - "print(\"t-shirt:\", inventory[\"t-shirt\"])\n", - "print(\"mug:\", inventory[\"mug\"])\n", - "print(\"hat:\", inventory[\"hat\"])\n", - "print(\"book:\", inventory[\"book\"])\n", - "print(\"keychain:\", inventory[\"keychain\"])" + "order_status = (total_products_ordered, percentage_ordered) # Tupla con las estadísticas\n" ] } ], From afc19cc07cd487d40bd36c6f1685d448014458c4 Mon Sep 17 00:00:00 2001 From: Juan Boberg Aguirre Date: Mon, 13 Apr 2026 17:54:03 +0200 Subject: [PATCH 4/4] Update lab-python-data-structures.ipynb --- lab-python-data-structures.ipynb | 39 ++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 75f70a04..aab233df 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -77,13 +77,13 @@ } ], "source": [ - "# Paso 1: Definir la lista de productos\n", + "# Paso 1\n", "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", "\n", - "# Paso 2: Crear un diccionario vacío llamado inventory\n", + "# Paso 2\n", "inventory = {}\n", "\n", - "# Paso 3: Pedir la cantidad de cada producto al usuario\n", + "# Paso 3\n", "\n", "\n", "cantidad_tshirt = int(input(\"¿Cuánt@s t-shirt hay en inventario? \"))\n", @@ -98,10 +98,10 @@ "inventory[\"book\"] = cantidad_book\n", "inventory[\"keychain\"] = cantidad_keychain\n", "\n", - "# Paso 4: Crear un conjunto vacío llamado customer_orders\n", + "# Paso 4\n", "customer_orders = set()\n", "\n", - "# Paso 5: Pedir 3 productos al cliente \n", + "# Paso 5\n", "producto1 = input(\"Introduce el primer producto que desea pedir: \")\n", "producto2 = input(\"Introduce el segundo producto que desea pedir: \")\n", "producto3 = input(\"Introduce el tercer producto que desea pedir: \")\n", @@ -110,7 +110,7 @@ "customer_orders.add(producto2)\n", "customer_orders.add(producto3)\n", "\n", - "# Paso 6: Imprimir los productos del conjunto customer_orders\n", + "# Paso 6\n", "print(\"Productos pedidos:\")\n", "for producto in customer_orders:\n", " print(producto)\n", @@ -119,7 +119,32 @@ "total_products_ordered = len(customer_orders) # Total de productos pedidos\n", "total_available_products = len(products) # Total de productos disponibles\n", "percentage_ordered = (total_products_ordered / total_available_products) * 100\n", - "order_status = (total_products_ordered, percentage_ordered) # Tupla con las estadísticas\n" + "order_status = (total_products_ordered, percentage_ordered) # Tupla con las estadísticas\n", + "\n", + "# Paso 8\n", + "print(\"Order Statistics:\")\n", + "print(f\"Total Products Ordered: {order_status[0]}\")\n", + "print(f\"Percentage of Products Ordered: {order_status[1]:.2f}%\")\n", + "\n", + "# Paso 9\n", + "if \"t-shirt\" in customer_orders:\n", + " inventory[\"t-shirt\"] -= 1\n", + "if \"mug\" in customer_orders:\n", + " inventory[\"mug\"] -= 1\n", + "if \"hat\" in customer_orders:\n", + " inventory[\"hat\"] -= 1\n", + "if \"book\" in customer_orders:\n", + " inventory[\"book\"] -= 1\n", + "if \"keychain\" in customer_orders:\n", + " inventory[\"keychain\"] -= 1\n", + "\n", + "# Paso 10\n", + "print(\"Inventario actualizado:\")\n", + "print(\"t-shirt:\", inventory[\"t-shirt\"])\n", + "print(\"mug:\", inventory[\"mug\"])\n", + "print(\"hat:\", inventory[\"hat\"])\n", + "print(\"book:\", inventory[\"book\"])\n", + "print(\"keychain:\", inventory[\"keychain\"])" ] } ],