From 7fed0aa9a285293e7b933f88ff2ffa655669a6be Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Tue, 15 Sep 2026 17:23:29 +0200 Subject: [PATCH 1/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 44d337b..17f3386 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -43,6 +43,14 @@ "\n", "\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "9aebe77d", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From d989006957ad4c40e558c86ae33faf4b43bac695 Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Wed, 16 Sep 2026 11:22:45 +0200 Subject: [PATCH 2/8] hasta el ejercicio 3 --- lab-python-functions.ipynb | 191 ++++++++++++++++++++++++++++++++++++- 1 file changed, 189 insertions(+), 2 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 17f3386..6293b82 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -8,6 +8,14 @@ "# Lab | Functions" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "fa9944c1", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "id": "0c581062-8967-4d93-b06e-62833222f930", @@ -49,13 +57,192 @@ "execution_count": null, "id": "9aebe77d", "metadata": {}, + "outputs": [ + { + "ename": "IndentationError", + "evalue": "unindent does not match any outer indentation level (, line 22)", + "output_type": "error", + "traceback": [ + " \u001b[36mFile \u001b[39m\u001b[32m:22\u001b[39m\n\u001b[31m \u001b[39m\u001b[31mproducts.append(product.lower())\u001b[39m\n ^\n\u001b[31mIndentationError\u001b[39m\u001b[31m:\u001b[39m unindent does not match any outer indentation level\n" + ] + } + ], + "source": [ + "\n", + "inventory = {}\n", + "\n", + "def initialize_inventory(products):\n", + " \n", + " products = []\n", + "\n", + " for product in products:\n", + " quantity = int(input(f\"¿Cuántas unidades de {product} hay? \"))\n", + "\n", + " inventory[product] = quantity\n", + "\n", + " return inventory\n", + "\n", + "def get_customer_orders():\n", + "\n", + " customer_orders = set()\n", + "\n", + " seguir_comprando = 'yes'\n", + "\n", + " while seguir_comprando == 'yes':\n", + "\n", + " product = input('INTRODUCE')\n", + "\n", + " customer_orders.add(product)\n", + "\n", + " seguir_comprando = input('Quieres seguir comprando')\n", + "\n", + "\n", + " return customer_orders\n", + "\n", + "\n", + "\n", + "\n", + "def get_customer_orders():\n", + "\n", + " customer_orders = set()\n", + "\n", + " product = input ('INTRODUCE')\n", + "\n", + " customer_orders.add(product)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "339d1077", + "metadata": {}, "outputs": [], "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5abba42e", + "metadata": {}, + "outputs": [], + "source": [ + "def get_customer_orders():\n", + "\n", + " customer_orders = set()\n", + "\n", + " seguir_comprando = 'yes'\n", + "\n", + " while seguir_comprando == 'yes':\n", + "\n", + " product = input('INTRODUCE')\n", + "\n", + " customer_orders.add(product)\n", + "\n", + " seguir_comprando = input('Quieres seguir comprando')\n", + "\n", + "\n", + " return customer_orders\n", + "\n", + "customer_orders = get_customer_orders()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "67b157a5", + "metadata": {}, + "outputs": [], + "source": [ + "for p in customer_orders:\n", + "\n", + " inventory[p] = inventory[p] - 1\n", + "\n", + "def update_inventory(customer_order, inventory):\n", + "\n", + " for p in customer_order:\n", + "\n", + " inventory[p] = inventory[p] - 1\n", + "\n", + " return inventory\n", + "\n", + "update_inventory(customer_order, inventory)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "daf170ce", + "metadata": {}, + "outputs": [], + "source": [ + "#ESTE CODIGO ES PARA VER EL UN ORDEN CLARO DEL CODIGO, realmente se \n", + "#ponen las funciones al principio.\n", + "\n", + "inventory = {}\n", + "\n", + "def initialize_inventory(products):\n", + " \n", + " products = []\n", + "\n", + " for product in products:\n", + " quantity = int(input(f\"¿Cuántas unidades de {product} hay? \"))\n", + "\n", + " inventory[product] = quantity\n", + "\n", + " return inventory\n", + "\n", + "def get_customer_orders():\n", + "\n", + " customer_orders = set()\n", + "\n", + " seguir_comprando = 'yes'\n", + "\n", + " while seguir_comprando == 'yes':\n", + "\n", + " product = input('INTRODUCE')\n", + "\n", + " customer_orders.add(product)\n", + "\n", + " seguir_comprando = input('Quieres seguir comprando')\n", + "\n", + "\n", + " return customer_orders\n", + "\n", + "\n", + "def update_inventory(customer_order, inventory):\n", + "\n", + " for p in customer_order:\n", + "\n", + " inventory[p] = inventory[p] - 1\n", + "\n", + " return inventory\n", + "\n", + "update_inventory(customer_orders, inventory)\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "41c85b18", + "metadata": {}, + "outputs": [], + "source": [ + "product =[]\n", + "\n", + "inventory = initialize_inventory( product)\n", + "\n", + "customer_order = get_customer_orders()\n", + "\n", + "update_inventory(customer_order, inventory)\n", + "\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -69,7 +256,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.6" } }, "nbformat": 4, From 762cd2da5230f48426d99ced19e97a9510a43ffe Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Wed, 16 Sep 2026 11:33:16 +0200 Subject: [PATCH 3/8] cambios en el ejercicio 3 --- lab-python-functions.ipynb | 77 ++++++++++++++------------------------ 1 file changed, 29 insertions(+), 48 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 6293b82..e0a524e 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -54,21 +54,12 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "9aebe77d", "metadata": {}, - "outputs": [ - { - "ename": "IndentationError", - "evalue": "unindent does not match any outer indentation level (, line 22)", - "output_type": "error", - "traceback": [ - " \u001b[36mFile \u001b[39m\u001b[32m:22\u001b[39m\n\u001b[31m \u001b[39m\u001b[31mproducts.append(product.lower())\u001b[39m\n ^\n\u001b[31mIndentationError\u001b[39m\u001b[31m:\u001b[39m unindent does not match any outer indentation level\n" - ] - } - ], + "outputs": [], "source": [ - "\n", + "##EJERCICIO 1\n", "inventory = {}\n", "\n", "def initialize_inventory(products):\n", @@ -81,34 +72,7 @@ " inventory[product] = quantity\n", "\n", " return inventory\n", - "\n", - "def get_customer_orders():\n", - "\n", - " customer_orders = set()\n", - "\n", - " seguir_comprando = 'yes'\n", - "\n", - " while seguir_comprando == 'yes':\n", - "\n", - " product = input('INTRODUCE')\n", - "\n", - " customer_orders.add(product)\n", - "\n", - " seguir_comprando = input('Quieres seguir comprando')\n", - "\n", - "\n", - " return customer_orders\n", - "\n", - "\n", - "\n", - "\n", - "def get_customer_orders():\n", - "\n", - " customer_orders = set()\n", - "\n", - " product = input ('INTRODUCE')\n", - "\n", - " customer_orders.add(product)" + "\n" ] }, { @@ -121,11 +85,13 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "5abba42e", "metadata": {}, "outputs": [], "source": [ + "#EJERCICIO 2\n", + "\n", "def get_customer_orders():\n", "\n", " customer_orders = set()\n", @@ -148,24 +114,39 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "id": "67b157a5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "KeyError", + "evalue": "'MANZANA'", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mKeyError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 15\u001b[39m\n\u001b[32m 11\u001b[39m inventory[p] = inventory[p] - \u001b[32m1\u001b[39m\n\u001b[32m 12\u001b[39m \n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m inventory\n\u001b[32m 14\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m15\u001b[39m update_inventory(customer_orders, inventory)\n", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 11\u001b[39m, in \u001b[36mupdate_inventory\u001b[39m\u001b[34m(customer_orders, inventory)\u001b[39m\n\u001b[32m 7\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m update_inventory(customer_orders, inventory):\n\u001b[32m 8\u001b[39m \n\u001b[32m 9\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m p \u001b[38;5;28;01min\u001b[39;00m customer_orders:\n\u001b[32m 10\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m11\u001b[39m inventory[p] = inventory[p] - \u001b[32m1\u001b[39m\n\u001b[32m 12\u001b[39m \n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m inventory\n", + "\u001b[31mKeyError\u001b[39m: 'MANZANA'" + ] + } + ], "source": [ - "for p in customer_orders:\n", + "##for p in customer_orders:\n", "\n", - " inventory[p] = inventory[p] - 1\n", + "## inventory[p] = inventory[p] - 1\n", "\n", - "def update_inventory(customer_order, inventory):\n", + "#EJERCICIO 3\n", "\n", - " for p in customer_order:\n", + "def update_inventory(customer_orders, inventory):\n", + "\n", + " for p in customer_orders:\n", "\n", " inventory[p] = inventory[p] - 1\n", "\n", " return inventory\n", "\n", - "update_inventory(customer_order, inventory)\n" + "update_inventory(customer_orders, inventory)\n" ] }, { From d55050a62525af7fd2f3fb6d26a1baba1eabdf66 Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Wed, 16 Sep 2026 12:43:47 +0200 Subject: [PATCH 4/8] ejercicio 4 hecho --- lab-python-functions.ipynb | 225 ++++++++++++++++++++++++++++++++----- 1 file changed, 199 insertions(+), 26 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index e0a524e..34f9a41 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -54,17 +54,18 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 49, "id": "9aebe77d", "metadata": {}, "outputs": [], "source": [ "##EJERCICIO 1\n", - "inventory = {}\n", + "\n", + "products = ['hat', 'skirt', 'shoes']\n", "\n", "def initialize_inventory(products):\n", - " \n", - " products = []\n", + "\n", + " inventory = {}\n", "\n", " for product in products:\n", " quantity = int(input(f\"¿Cuántas unidades de {product} hay? \"))\n", @@ -77,15 +78,38 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 50, "id": "339d1077", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "inventory = initialize_inventory(products)" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "e0722459", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'hat': 100, 'skirt': 56, 'shoes': 333}" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory" + ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 52, "id": "5abba42e", "metadata": {}, "outputs": [], @@ -100,37 +124,55 @@ "\n", " while seguir_comprando == 'yes':\n", "\n", - " product = input('INTRODUCE')\n", + " product = input('INTRODUCE QUE QUIERES COMPRAR')\n", "\n", " customer_orders.add(product)\n", "\n", " seguir_comprando = input('Quieres seguir comprando')\n", "\n", "\n", - " return customer_orders\n", + " return customer_orders\n", "\n", - "customer_orders = get_customer_orders()\n" + "\n" ] }, { "cell_type": "code", - "execution_count": 7, - "id": "67b157a5", + "execution_count": 53, + "id": "4ac0e6de", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = get_customer_orders()" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "id": "0197a998", "metadata": {}, "outputs": [ { - "ename": "KeyError", - "evalue": "'MANZANA'", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mKeyError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 15\u001b[39m\n\u001b[32m 11\u001b[39m inventory[p] = inventory[p] - \u001b[32m1\u001b[39m\n\u001b[32m 12\u001b[39m \n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m inventory\n\u001b[32m 14\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m15\u001b[39m update_inventory(customer_orders, inventory)\n", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[7]\u001b[39m\u001b[32m, line 11\u001b[39m, in \u001b[36mupdate_inventory\u001b[39m\u001b[34m(customer_orders, inventory)\u001b[39m\n\u001b[32m 7\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m update_inventory(customer_orders, inventory):\n\u001b[32m 8\u001b[39m \n\u001b[32m 9\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m p \u001b[38;5;28;01min\u001b[39;00m customer_orders:\n\u001b[32m 10\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m11\u001b[39m inventory[p] = inventory[p] - \u001b[32m1\u001b[39m\n\u001b[32m 12\u001b[39m \n\u001b[32m 13\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m inventory\n", - "\u001b[31mKeyError\u001b[39m: 'MANZANA'" - ] + "data": { + "text/plain": [ + "{'skirt'}" + ] + }, + "execution_count": 54, + "metadata": {}, + "output_type": "execute_result" } ], + "source": [ + "customer_orders" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "id": "67b157a5", + "metadata": {}, + "outputs": [], "source": [ "##for p in customer_orders:\n", "\n", @@ -140,15 +182,130 @@ "\n", "def update_inventory(customer_orders, inventory):\n", "\n", - " for p in customer_orders:\n", + " for new_inventory in customer_orders:\n", "\n", - " inventory[p] = inventory[p] - 1\n", + " inventory[new_inventory] = inventory[new_inventory] - 1\n", "\n", - " return inventory\n", + " return inventory\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "id": "6dd325c2", + "metadata": {}, + "outputs": [], + "source": [ + "new_inventory = update_inventory(customer_orders, inventory)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "id": "9a841fe8", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'hat': 100, 'skirt': 55, 'shoes': 333}" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "new_inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "id": "7d0f9c0b", + "metadata": {}, + "outputs": [], + "source": [ + "#EJERCICIO 4\n", + "\n", + "def calculate_order_statics(customer_orders, products):\n", + "\n", + " total_products= len(customer_orders)\n", + "\n", + " unique_products = set(customer_orders)\n", + "\n", + " number_unique = len(unique_products)\n", + "\n", + " percentage_unique = (number_unique / total_products) * 100\n", "\n", - "update_inventory(customer_orders, inventory)\n" + " return total_products , percentage_unique" ] }, + { + "cell_type": "code", + "execution_count": 61, + "id": "8d36fe3e", + "metadata": {}, + "outputs": [], + "source": [ + "percentage_unique = calculate_order_statics(customer_orders, products)" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "id": "93e475ee", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(1, 100.0)" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "percentage_unique" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f1fd8536", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "c95a4195", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cc618757", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8c1bd59b", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": null, @@ -200,6 +357,18 @@ "\n", "update_inventory(customer_orders, inventory)\n", "\n", + "def calculate_order_statistics(customer_orders, products):\n", + "\n", + " total_products= len(customer_orders)\n", + "\n", + " unique_products = set(customer_orders)\n", + "\n", + " number_unique = len(unique_products)\n", + "\n", + " percentage_unique = number_unique / total_products *100\n", + "\n", + " return total_products , percentage_unique\n", + "\n", "\n" ] }, @@ -217,6 +386,10 @@ "customer_order = get_customer_orders()\n", "\n", "update_inventory(customer_order, inventory)\n", + "\n", + "calculate_order_statistics(customer_orders, products)\n", + "\n", + "\n", "\n" ] } From 40e36025948f8788241dc9f408dddc568b8eaead Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Wed, 16 Sep 2026 14:42:00 +0200 Subject: [PATCH 5/8] ejercicio hecho --- lab-python-functions.ipynb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 34f9a41..a4d4922 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -223,14 +223,14 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 64, "id": "7d0f9c0b", "metadata": {}, "outputs": [], "source": [ "#EJERCICIO 4\n", "\n", - "def calculate_order_statics(customer_orders, products):\n", + "def calculate_order_statistics(customer_orders, products):\n", "\n", " total_products= len(customer_orders)\n", "\n", @@ -245,17 +245,17 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 65, "id": "8d36fe3e", "metadata": {}, "outputs": [], "source": [ - "percentage_unique = calculate_order_statics(customer_orders, products)" + "percentage_unique = calculate_order_statistics(customer_orders, products)" ] }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 66, "id": "93e475ee", "metadata": {}, "outputs": [ @@ -265,7 +265,7 @@ "(1, 100.0)" ] }, - "execution_count": 62, + "execution_count": 66, "metadata": {}, "output_type": "execute_result" } From 5ef30252e517b32296efa8f3790df4435cde627a Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Wed, 16 Sep 2026 14:55:03 +0200 Subject: [PATCH 6/8] ejerciocios completados --- lab-python-functions.ipynb | 131 ++++++++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 31 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index a4d4922..e9a0cb0 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -54,7 +54,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 4, "id": "9aebe77d", "metadata": {}, "outputs": [], @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 5, "id": "339d1077", "metadata": {}, "outputs": [], @@ -88,17 +88,17 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 6, "id": "e0722459", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'hat': 100, 'skirt': 56, 'shoes': 333}" + "{'hat': 50, 'skirt': 60, 'shoes': 70}" ] }, - "execution_count": 51, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -109,7 +109,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 12, "id": "5abba42e", "metadata": {}, "outputs": [], @@ -138,7 +138,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 13, "id": "4ac0e6de", "metadata": {}, "outputs": [], @@ -148,17 +148,17 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 14, "id": "0197a998", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'skirt'}" + "{'hat', 'shoes'}" ] }, - "execution_count": 54, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -169,7 +169,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 15, "id": "67b157a5", "metadata": {}, "outputs": [], @@ -192,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 17, "id": "6dd325c2", "metadata": {}, "outputs": [], @@ -202,17 +202,17 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 18, "id": "9a841fe8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'hat': 100, 'skirt': 55, 'shoes': 333}" + "{'hat': 47, 'skirt': 60, 'shoes': 68}" ] }, - "execution_count": 57, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -223,7 +223,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 25, "id": "7d0f9c0b", "metadata": {}, "outputs": [], @@ -234,18 +234,20 @@ "\n", " total_products= len(customer_orders)\n", "\n", - " unique_products = set(customer_orders)\n", + " #unique_products = set(customer_orders)\n", "\n", - " number_unique = len(unique_products)\n", + " #number_unique = len(unique_products)\n", "\n", - " percentage_unique = (number_unique / total_products) * 100\n", + " percentage_unique = len(customer_orders) / total_products * 100\n", + "\n", + " #len(customer_orders)\n", "\n", " return total_products , percentage_unique" ] }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 26, "id": "8d36fe3e", "metadata": {}, "outputs": [], @@ -255,17 +257,17 @@ }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 22, "id": "93e475ee", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(1, 100.0)" + "(2, 100.0)" ] }, - "execution_count": 66, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -276,19 +278,46 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "f1fd8536", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "#EJERCICIO 5\n", + "\n", + "def print_order_statistics(order_statistics):\n", + "\n", + " print(\"Total de productos pedidos\", order_statistics[0])\n", + "\n", + " print(\"Porcentaje\", order_statistics[1])\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n" + ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 28, "id": "c95a4195", "metadata": {}, - "outputs": [], - "source": [] + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total de productos pedidos 2\n", + "Porcentaje 100.0\n" + ] + } + ], + "source": [ + "order_statistics = calculate_order_statistics(customer_orders, products)\n", + "\n", + "print_order_statistics(order_statistics)" + ] }, { "cell_type": "code", @@ -296,14 +325,51 @@ "id": "cc618757", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "#EJERCICIO 6\n", + "\n", + "def print_updated_inventory(inventory):\n", + "\n", + " print(\"Inventario es:\", new_inventory)\n" + ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 43, "id": "8c1bd59b", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Inventario es: {'hat': 37, 'skirt': 60, 'shoes': 58}\n" + ] + } + ], + "source": [ + "new_inventory = update_inventory(customer_orders, inventory)\n", + "\n", + "print_updated_inventory(new_inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd003e3e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'hat': 43, 'skirt': 60, 'shoes': 64}" + ] + }, + "execution_count": 37, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [] }, { @@ -389,6 +455,9 @@ "\n", "calculate_order_statistics(customer_orders, products)\n", "\n", + "print_order_statistics(order_statistics)\n", + "\n", + "print_updated_inventory(new_inventory)\n", "\n", "\n" ] From 850b5cab847defc8ac3668e6d0ffec20fb8561b3 Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Wed, 16 Sep 2026 15:14:24 +0200 Subject: [PATCH 7/8] =?UTF-8?q?FINALIZADO=20con=20un=20peque=C3=B1o=20mati?= =?UTF-8?q?z=20a=20corregir?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab-python-functions.ipynb | 86 +++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index e9a0cb0..dd27ddb 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -54,7 +54,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "id": "9aebe77d", "metadata": {}, "outputs": [], @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 2, "id": "339d1077", "metadata": {}, "outputs": [], @@ -88,17 +88,17 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 3, "id": "e0722459", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'hat': 50, 'skirt': 60, 'shoes': 70}" + "{'hat': 5, 'skirt': 5, 'shoes': 5}" ] }, - "execution_count": 6, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -109,7 +109,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 4, "id": "5abba42e", "metadata": {}, "outputs": [], @@ -138,7 +138,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 5, "id": "4ac0e6de", "metadata": {}, "outputs": [], @@ -148,17 +148,17 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 6, "id": "0197a998", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'hat', 'shoes'}" + "{'shoes'}" ] }, - "execution_count": 14, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -169,7 +169,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 7, "id": "67b157a5", "metadata": {}, "outputs": [], @@ -192,7 +192,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 8, "id": "6dd325c2", "metadata": {}, "outputs": [], @@ -202,17 +202,17 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 9, "id": "9a841fe8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'hat': 47, 'skirt': 60, 'shoes': 68}" + "{'hat': 5, 'skirt': 5, 'shoes': 4}" ] }, - "execution_count": 18, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -223,7 +223,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 10, "id": "7d0f9c0b", "metadata": {}, "outputs": [], @@ -247,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 11, "id": "8d36fe3e", "metadata": {}, "outputs": [], @@ -257,17 +257,17 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 12, "id": "93e475ee", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(2, 100.0)" + "(1, 100.0)" ] }, - "execution_count": 22, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -278,7 +278,7 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 13, "id": "f1fd8536", "metadata": {}, "outputs": [], @@ -300,7 +300,7 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 14, "id": "c95a4195", "metadata": {}, "outputs": [ @@ -308,7 +308,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Total de productos pedidos 2\n", + "Total de productos pedidos 1\n", "Porcentaje 100.0\n" ] } @@ -321,7 +321,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 15, "id": "cc618757", "metadata": {}, "outputs": [], @@ -335,7 +335,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 16, "id": "8c1bd59b", "metadata": {}, "outputs": [ @@ -343,7 +343,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Inventario es: {'hat': 37, 'skirt': 60, 'shoes': 58}\n" + "Inventario es: {'hat': 5, 'skirt': 5, 'shoes': 3}\n" ] } ], @@ -358,23 +358,12 @@ "execution_count": null, "id": "bd003e3e", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'hat': 43, 'skirt': 60, 'shoes': 64}" - ] - }, - "execution_count": 37, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 18, "id": "daf170ce", "metadata": {}, "outputs": [], @@ -421,7 +410,7 @@ "\n", " return inventory\n", "\n", - "update_inventory(customer_orders, inventory)\n", + "\n", "\n", "def calculate_order_statistics(customer_orders, products):\n", "\n", @@ -440,10 +429,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "41c85b18", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "KeyError", + "evalue": "'shoes'", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mKeyError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[19]\u001b[39m\u001b[32m, line 7\u001b[39m\n\u001b[32m 3\u001b[39m inventory = initialize_inventory( product)\n\u001b[32m 4\u001b[39m \n\u001b[32m 5\u001b[39m customer_order = get_customer_orders()\n\u001b[32m 6\u001b[39m \n\u001b[32m----> \u001b[39m\u001b[32m7\u001b[39m update_inventory(customer_order, inventory)\n\u001b[32m 8\u001b[39m \n\u001b[32m 9\u001b[39m calculate_order_statistics(customer_orders, products)\n\u001b[32m 10\u001b[39m \n", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[18]\u001b[39m\u001b[32m, line 39\u001b[39m, in \u001b[36mupdate_inventory\u001b[39m\u001b[34m(customer_order, inventory)\u001b[39m\n\u001b[32m 35\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m update_inventory(customer_order, inventory):\n\u001b[32m 36\u001b[39m \n\u001b[32m 37\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m p \u001b[38;5;28;01min\u001b[39;00m customer_order:\n\u001b[32m 38\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m39\u001b[39m inventory[p] = inventory[p] - \u001b[32m1\u001b[39m\n\u001b[32m 40\u001b[39m \n\u001b[32m 41\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m inventory\n", + "\u001b[31mKeyError\u001b[39m: 'shoes'" + ] + } + ], "source": [ "product =[]\n", "\n", From 71735d88fa50dfb55fb983ba6ca6732c1f62d110 Mon Sep 17 00:00:00 2001 From: Emeka Amadi Date: Wed, 16 Sep 2026 15:31:49 +0200 Subject: [PATCH 8/8] FINALIZADO Y sin error --- lab-python-functions.ipynb | 76 +++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index dd27ddb..b3ac9be 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -54,14 +54,14 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 50, "id": "9aebe77d", "metadata": {}, "outputs": [], "source": [ "##EJERCICIO 1\n", "\n", - "products = ['hat', 'skirt', 'shoes']\n", + "products = ['hat', 'skirt', 'shoes','t-shirt', 'car', 'motorcycle', 'socks']\n", "\n", "def initialize_inventory(products):\n", "\n", @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 51, "id": "339d1077", "metadata": {}, "outputs": [], @@ -88,17 +88,23 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 52, "id": "e0722459", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'hat': 5, 'skirt': 5, 'shoes': 5}" + "{'hat': 7,\n", + " 'skirt': 7,\n", + " 'shoes': 7,\n", + " 't-shirt': 7,\n", + " 'car': 7,\n", + " 'motorcycle': 7,\n", + " 'socks': 7}" ] }, - "execution_count": 3, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -109,7 +115,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 73, "id": "5abba42e", "metadata": {}, "outputs": [], @@ -138,7 +144,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 74, "id": "4ac0e6de", "metadata": {}, "outputs": [], @@ -148,17 +154,17 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 75, "id": "0197a998", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'shoes'}" + "{'car', 't-shirt'}" ] }, - "execution_count": 6, + "execution_count": 75, "metadata": {}, "output_type": "execute_result" } @@ -169,7 +175,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 76, "id": "67b157a5", "metadata": {}, "outputs": [], @@ -192,7 +198,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 78, "id": "6dd325c2", "metadata": {}, "outputs": [], @@ -202,17 +208,23 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 79, "id": "9a841fe8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'hat': 5, 'skirt': 5, 'shoes': 4}" + "{'hat': 7,\n", + " 'skirt': 7,\n", + " 'shoes': 7,\n", + " 't-shirt': 5,\n", + " 'car': 4,\n", + " 'motorcycle': 7,\n", + " 'socks': 7}" ] }, - "execution_count": 9, + "execution_count": 79, "metadata": {}, "output_type": "execute_result" } @@ -223,7 +235,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 85, "id": "7d0f9c0b", "metadata": {}, "outputs": [], @@ -232,42 +244,40 @@ "\n", "def calculate_order_statistics(customer_orders, products):\n", "\n", - " total_products= len(customer_orders)\n", - "\n", - " #unique_products = set(customer_orders)\n", + " total_products_order = len(customer_orders)\n", "\n", - " #number_unique = len(unique_products)\n", + " unique_products = (customer_orders)\n", "\n", - " percentage_unique = len(customer_orders) / total_products * 100\n", + " #number_unique = len(set(unique_products))\n", "\n", - " #len(customer_orders)\n", + " percentage_unique = total_products_order / len(products) * 100\n", "\n", - " return total_products , percentage_unique" + " return total_products_order , percentage_unique" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 86, "id": "8d36fe3e", "metadata": {}, "outputs": [], "source": [ - "percentage_unique = calculate_order_statistics(customer_orders, products)" + "percentage_unique = calculate_order_statistics(set(customer_orders), products)" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 87, "id": "93e475ee", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(1, 100.0)" + "(2, 28.57142857142857)" ] }, - "execution_count": 12, + "execution_count": 87, "metadata": {}, "output_type": "execute_result" } @@ -278,7 +288,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 48, "id": "f1fd8536", "metadata": {}, "outputs": [], @@ -300,7 +310,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 49, "id": "c95a4195", "metadata": {}, "outputs": [ @@ -308,8 +318,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "Total de productos pedidos 1\n", - "Porcentaje 100.0\n" + "Total de productos pedidos 7\n", + "Porcentaje 57.14285714285714\n" ] } ],