From 43e24e08ea7b1dfe52fa74b223fe37fa2470ec4e Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Tue, 15 Sep 2026 16:56:19 +0200 Subject: [PATCH 1/5] codigo parte 1 falta ejercicio 3 --- lab-python-flow-control.ipynb | 47 +++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..0c80754 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,11 +37,54 @@ "\n", "3. Instead of updating the inventory by subtracting 1 from the quantity of each product, only do it for the products that were ordered (those in \"customer_orders\")." ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "c6fa05a1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tu lista de producto está vacío\n", + "Okey! Tu lista de compras es: {'manzana'}\n" + ] + } + ], + "source": [ + "product_list = set()\n", + "\n", + "print(\"Tu lista de producto está vacío\")\n", + "\n", + "\n", + "product = input (\"Dime que quieres comprar\")\n", + "\n", + "while product.lower() != \"\" and product.lower() != \"nada\":\n", + " \n", + " product_list.add(product.lower())\n", + "\n", + " respuesta = input(\"Quires añadir otro producto?si/no\")\n", + " \n", + " if respuesta.lower() == \"si\":\n", + "\n", + " product = input(\"Que mas quieres añadir?\")\n", + "\n", + " elif respuesta.lower() == \"no\":\n", + " break\n", + "\n", + " else:\n", + " print(\"opcion no valida\")\n", + " break\n", + "\n", + "print(\"Okey! Tu lista de compras es:\", product_list)\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -55,7 +98,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.6" } }, "nbformat": 4, From d904f4bbe968a3971597ce60f2a51896395877f9 Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Fri, 18 Sep 2026 16:21:03 +0200 Subject: [PATCH 2/5] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 0c80754..434305f 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "id": "c6fa05a1", "metadata": {}, "outputs": [ @@ -49,7 +49,33 @@ "output_type": "stream", "text": [ "Tu lista de producto está vacío\n", - "Okey! Tu lista de compras es: {'manzana'}\n" + "Okey! Tu lista de compras es: {'melocotones', 'manzana', 'peras', 'sacos'}\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n", + "Ese producto no está disponible.\n" + ] + }, + { + "ename": "", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n", + "\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n", + "\u001b[1;31mClick here for more info. \n", + "\u001b[1;31mView Jupyter log for further details." ] } ], From 0895382547d8d93f64f0eecf3003f358ba229766 Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Fri, 18 Sep 2026 16:32:43 +0200 Subject: [PATCH 3/5] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 44 +++++++++++++---------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 434305f..2076831 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "c6fa05a1", "metadata": {}, "outputs": [ @@ -49,37 +49,14 @@ "output_type": "stream", "text": [ "Tu lista de producto está vacío\n", - "Okey! Tu lista de compras es: {'melocotones', 'manzana', 'peras', 'sacos'}\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n", - "Ese producto no está disponible.\n" - ] - }, - { - "ename": "", - "evalue": "", - "output_type": "error", - "traceback": [ - "\u001b[1;31mThe Kernel crashed while executing code in the current cell or a previous cell. \n", - "\u001b[1;31mPlease review the code in the cell(s) to identify a possible cause of the failure. \n", - "\u001b[1;31mClick here for more info. \n", - "\u001b[1;31mView Jupyter log for further details." + "Okey! Tu lista de compras es: {'zanahorias', 'peras', 'albaricoques', 'manzanas', 'naranjas'}\n" ] } ], "source": [ + "\n", + "#EJERCICIO 2\n", + "\n", "product_list = set()\n", "\n", "print(\"Tu lista de producto está vacío\")\n", @@ -106,6 +83,17 @@ "\n", "print(\"Okey! Tu lista de compras es:\", product_list)\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "64c4c9f5", + "metadata": {}, + "outputs": [], + "source": [ + "#EJERCICIO 3\n", + "\n" + ] } ], "metadata": { From 694c8867e7f37bc989959baa6b0a0cdcbf8673bf Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Fri, 18 Sep 2026 17:44:02 +0200 Subject: [PATCH 4/5] ejercicio 3 hecho --- lab-python-flow-control.ipynb | 137 +++++++++++++++++++++++++++++----- 1 file changed, 118 insertions(+), 19 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 2076831..b897cf0 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -49,39 +49,79 @@ "output_type": "stream", "text": [ "Tu lista de producto está vacío\n", - "Okey! Tu lista de compras es: {'zanahorias', 'peras', 'albaricoques', 'manzanas', 'naranjas'}\n" + "Okey! Tu lista de compras es: {'maquinas', 'cafe'}\n" + ] + }, + { + "ename": "TypeError", + "evalue": "'set' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mTypeError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[5]\u001b[39m\u001b[32m, line 31\u001b[39m\n\u001b[32m 27\u001b[39m print(\u001b[33m\"Okey! Tu lista de compras es:\"\u001b[39m, product_list)\n\u001b[32m 28\u001b[39m \n\u001b[32m 29\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m product \u001b[38;5;28;01min\u001b[39;00m product_list:\n\u001b[32m 30\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m31\u001b[39m product_list[product] = product_list[product] - \u001b[32m1\u001b[39m\n\u001b[32m 32\u001b[39m \n\u001b[32m 33\u001b[39m print(\u001b[33m\"Updated stock after order:\"\u001b[39m, product_list)\n\u001b[32m 34\u001b[39m \n", + "\u001b[31mTypeError\u001b[39m: 'set' object is not subscriptable" ] } ], "source": [ "\n", - "#EJERCICIO 2\n", + "#EJERCICIO\n", "\n", - "product_list = set()\n", + "product_list = set() \n", "\n", - "print(\"Tu lista de producto está vacío\")\n", + "print(\"Tu lista de producto está vacío\") \n", "\n", + "product = input (\"Dime que quieres comprar\") \n", "\n", - "product = input (\"Dime que quieres comprar\")\n", + "while product.lower() != \"\" and product.lower() != \"nada\": \n", "\n", - "while product.lower() != \"\" and product.lower() != \"nada\":\n", - " \n", - " product_list.add(product.lower())\n", + " product_list.add(product.lower()) \n", "\n", - " respuesta = input(\"Quires añadir otro producto?si/no\")\n", - " \n", - " if respuesta.lower() == \"si\":\n", + " respuesta = input(\"Quires añadir otro producto?si/no\") \n", + "\n", + " if respuesta.lower() == \"si\": \n", + "\n", + " product = input(\"Que mas quieres añadir?\") \n", + "\n", + " elif respuesta.lower() == \"no\": \n", "\n", - " product = input(\"Que mas quieres añadir?\")\n", + " break \n", "\n", - " elif respuesta.lower() == \"no\":\n", - " break\n", + " else: print(\"opcion no valida\") \n", "\n", - " else:\n", - " print(\"opcion no valida\")\n", - " break\n", + " break \n", "\n", - "print(\"Okey! Tu lista de compras es:\", product_list)\n" + "print(\"Okey! Tu lista de compras es:\", product_list) \n", + "\n", + "\n", + "for product in product_list:\n", + "\n", + " product_list[product] = product_list[product] - 1 \n", + "\n", + " print(\"Updated stock after order:\", product_list)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb09da20", + "metadata": {}, + "outputs": [ + { + "ename": "TypeError", + "evalue": "'set' object is not subscriptable", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mTypeError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 2\u001b[39m inventory = set()\n\u001b[32m 3\u001b[39m \n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m product \u001b[38;5;28;01min\u001b[39;00m product_list:\n\u001b[32m 5\u001b[39m \n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m inventory[product] = inventory[product] - \u001b[32m1\u001b[39m\n\u001b[32m 7\u001b[39m \n\u001b[32m 8\u001b[39m print(\u001b[33m\"Updated stock after order:\"\u001b[39m, inventory)\n", + "\u001b[31mTypeError\u001b[39m: 'set' object is not subscriptable" + ] + } + ], + "source": [ + "\n" ] }, { @@ -92,7 +132,66 @@ "outputs": [], "source": [ "#EJERCICIO 3\n", - "\n" + "\n", + "\n", + "\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "inventory = {}\n", + "\n", + "quantity0 = int(input(f\"Enter the quantity for {products[0]}: \"))\n", + "inventory[products[0]] = quantity0\n", + "\n", + "quantity1 = int(input(f\"Enter the quantity for {products[1]}: \"))\n", + "inventory[products[1]] = quantity1\n", + "\n", + "quantity2 = int(input(f\"Enter the quantity for {products[2]}: \"))\n", + "inventory[products[2]] = quantity2\n", + "\n", + "quantity3 = int(input(f\"Enter the quantity for {products[3]}: \"))\n", + "inventory[products[3]] = quantity3\n", + "\n", + "quantity4 = int(input(f\"Enter the quantity for {products[4]}: \"))\n", + "inventory[products[4]] = quantity4\n", + "\n", + "print(\" Your stock is as follows:\", inventory) \n", + "\n", + "\n", + "print(\"Now Give me the name of three products you want to order:\")\n", + "\n", + "customer_orders = set()\n", + "\n", + "customer_orders.add(input(\"Enter the name of your first product:\"))\n", + "customer_orders.add(input(\"Enter the name of your second product:\"))\n", + "customer_orders.add(input(\"Enter the name of your third product:\"))\n", + "\n", + "print(\"Your order is as follows:\", customer_orders)\n", + "\n", + "\n", + "total_products_ordered = len(customer_orders)\n", + "\n", + "percentage_products_ordered = (total_products_ordered / len(products)) * 100\n", + "\n", + "print(\"Order statistics:\")\n", + "\n", + "print(f\"Total Products Ordered: {total_products_ordered}\")\n", + "\n", + "print(f\"Percentage of Products Ordered: {percentage_products_ordered}\"\"%\")\n", + "\n", + "\n", + "inventory [\"t-shirt\"] = inventory[\"t-shirt\"] - 1\n", + "\n", + "inventory [\"mug\"] = inventory[\"mug\"] - 1\n", + "\n", + "inventory [\"hat\"] = inventory[\"hat\"] - 1\n", + "\n", + "inventory [\"book\"] = inventory[\"book\"] - 1\n", + "\n", + "inventory [\"keychain\"] = inventory[\"keychain\"] - 1\n", + "\n", + "\n", + "\n", + "print(\"Updated stock after order:\", inventory)\n" ] } ], From 15eaf950cb97e811614293d08d1e726a930bd648 Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Fri, 18 Sep 2026 17:45:37 +0200 Subject: [PATCH 5/5] un poco mas limpio --- lab-python-flow-control.ipynb | 143 ++++++++++++---------------------- 1 file changed, 51 insertions(+), 92 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index b897cf0..913078d 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -49,27 +49,24 @@ "output_type": "stream", "text": [ "Tu lista de producto está vacío\n", - "Okey! Tu lista de compras es: {'maquinas', 'cafe'}\n" - ] - }, - { - "ename": "TypeError", - "evalue": "'set' object is not subscriptable", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mTypeError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[5]\u001b[39m\u001b[32m, line 31\u001b[39m\n\u001b[32m 27\u001b[39m print(\u001b[33m\"Okey! Tu lista de compras es:\"\u001b[39m, product_list)\n\u001b[32m 28\u001b[39m \n\u001b[32m 29\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m product \u001b[38;5;28;01min\u001b[39;00m product_list:\n\u001b[32m 30\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m31\u001b[39m product_list[product] = product_list[product] - \u001b[32m1\u001b[39m\n\u001b[32m 32\u001b[39m \n\u001b[32m 33\u001b[39m print(\u001b[33m\"Updated stock after order:\"\u001b[39m, product_list)\n\u001b[32m 34\u001b[39m \n", - "\u001b[31mTypeError\u001b[39m: 'set' object is not subscriptable" + "Okey! Tu lista de compras es: {'keychain', 't-shirt', 'hat'}\n", + "Updated stock after order: {'t-shirt': 9, 'mug': 5, 'hat': 7, 'book': 4, 'keychain': 6}\n" ] } ], "source": [ "\n", - "#EJERCICIO\n", + "#EJERCICIO 2\n", "\n", "product_list = set() \n", "\n", + "inventory = {\n", + " \"t-shirt\": 10,\n", + " \"mug\": 5,\n", + " \"hat\": 8,\n", + " \"book\": 4,\n", + " \"keychain\": 7}\n", + "\n", "print(\"Tu lista de producto está vacío\") \n", "\n", "product = input (\"Dime que quieres comprar\") \n", @@ -88,110 +85,72 @@ "\n", " break \n", "\n", - " else: print(\"opcion no valida\") \n", + " else: \n", + "\n", + " print(\"opcion no valida\") \n", "\n", - " break \n", "\n", "print(\"Okey! Tu lista de compras es:\", product_list) \n", "\n", + "#PARTE 3 DEL EJERCICIO\n", "\n", - "for product in product_list:\n", + "for p in product_list:\n", "\n", - " product_list[product] = product_list[product] - 1 \n", + " inventory[p] = inventory[p] - 1 \n", "\n", - " print(\"Updated stock after order:\", product_list)" + "print(\"Updated stock after order:\", inventory)" ] }, { "cell_type": "code", - "execution_count": null, - "id": "fb09da20", + "execution_count": 8, + "id": "89f47251", "metadata": {}, "outputs": [ { - "ename": "TypeError", - "evalue": "'set' object is not subscriptable", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mTypeError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[3]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 2\u001b[39m inventory = set()\n\u001b[32m 3\u001b[39m \n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m product \u001b[38;5;28;01min\u001b[39;00m product_list:\n\u001b[32m 5\u001b[39m \n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m inventory[product] = inventory[product] - \u001b[32m1\u001b[39m\n\u001b[32m 7\u001b[39m \n\u001b[32m 8\u001b[39m print(\u001b[33m\"Updated stock after order:\"\u001b[39m, inventory)\n", - "\u001b[31mTypeError\u001b[39m: 'set' object is not subscriptable" - ] + "data": { + "text/plain": [ + "set()" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "\n" + "product_list" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "76c74d58", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'nada'" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "product " ] }, { "cell_type": "code", "execution_count": null, - "id": "64c4c9f5", + "id": "fb09da20", "metadata": {}, "outputs": [], "source": [ - "#EJERCICIO 3\n", - "\n", - "\n", - "\n", - "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", - "\n", - "inventory = {}\n", - "\n", - "quantity0 = int(input(f\"Enter the quantity for {products[0]}: \"))\n", - "inventory[products[0]] = quantity0\n", - "\n", - "quantity1 = int(input(f\"Enter the quantity for {products[1]}: \"))\n", - "inventory[products[1]] = quantity1\n", - "\n", - "quantity2 = int(input(f\"Enter the quantity for {products[2]}: \"))\n", - "inventory[products[2]] = quantity2\n", - "\n", - "quantity3 = int(input(f\"Enter the quantity for {products[3]}: \"))\n", - "inventory[products[3]] = quantity3\n", - "\n", - "quantity4 = int(input(f\"Enter the quantity for {products[4]}: \"))\n", - "inventory[products[4]] = quantity4\n", - "\n", - "print(\" Your stock is as follows:\", inventory) \n", - "\n", - "\n", - "print(\"Now Give me the name of three products you want to order:\")\n", - "\n", - "customer_orders = set()\n", - "\n", - "customer_orders.add(input(\"Enter the name of your first product:\"))\n", - "customer_orders.add(input(\"Enter the name of your second product:\"))\n", - "customer_orders.add(input(\"Enter the name of your third product:\"))\n", - "\n", - "print(\"Your order is as follows:\", customer_orders)\n", - "\n", - "\n", - "total_products_ordered = len(customer_orders)\n", - "\n", - "percentage_products_ordered = (total_products_ordered / len(products)) * 100\n", - "\n", - "print(\"Order statistics:\")\n", - "\n", - "print(f\"Total Products Ordered: {total_products_ordered}\")\n", - "\n", - "print(f\"Percentage of Products Ordered: {percentage_products_ordered}\"\"%\")\n", - "\n", - "\n", - "inventory [\"t-shirt\"] = inventory[\"t-shirt\"] - 1\n", - "\n", - "inventory [\"mug\"] = inventory[\"mug\"] - 1\n", - "\n", - "inventory [\"hat\"] = inventory[\"hat\"] - 1\n", - "\n", - "inventory [\"book\"] = inventory[\"book\"] - 1\n", - "\n", - "inventory [\"keychain\"] = inventory[\"keychain\"] - 1\n", - "\n", - "\n", - "\n", - "print(\"Updated stock after order:\", inventory)\n" + "\n" ] } ],