From da2c4780fc322a323d33afc2b4df8e657a437654 Mon Sep 17 00:00:00 2001 From: walnertpadron18 Date: Tue, 15 Sep 2026 16:59:56 +0100 Subject: [PATCH 1/3] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 56 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 44d337b..2a750f6 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -43,11 +43,63 @@ "\n", "\n" ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "c4ee8dff", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{}\n" + ] + } + ], + "source": [ + "def initialize_inventory(products):\n", + " inventory = {}\n", + " for product in products:\n", + " cantidad = int(input(f\"Ingresa la cantidad disponible para '{product}': \"))\n", + " return inventory\n", + "\n", + "\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = initialize_inventory(products)\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6e67e815", + "metadata": {}, + "outputs": [ + { + "ename": "SyntaxError", + "evalue": "expected ':' (4144453652.py, line 3)", + "output_type": "error", + "traceback": [ + " \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[14]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[31m \u001b[39m\u001b[31mwhile continuar ==\"yes\"\u001b[39m\n ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m expected ':'\n" + ] + } + ], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "897f2a77", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -61,7 +113,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.6" } }, "nbformat": 4, From a67acf970f9b928b205dfc8681d80facd3edf8dc Mon Sep 17 00:00:00 2001 From: walnertpadron18 Date: Wed, 16 Sep 2026 10:28:02 +0100 Subject: [PATCH 2/3] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 111 ++++++++++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 25 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 2a750f6..1577735 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -46,29 +46,21 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "c4ee8dff", + "execution_count": 65, + "id": "dcc1c843", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{}\n" - ] - } - ], + "outputs": [], "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", "def initialize_inventory(products):\n", " inventory = {}\n", - " for product in products:\n", - " cantidad = int(input(f\"Ingresa la cantidad disponible para '{product}': \"))\n", + " for i in products:\n", + " cantidad = int(input(f\"Ingresa la cantidad disponible para '{i}': \"))\n", + " inventory[i] = cantidad\n", " return inventory\n", "\n", - "\n", - "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", - "inventory = initialize_inventory(products)\n", - "print(inventory)" + "inventory = initialize_inventory(products)" ] }, { @@ -76,22 +68,91 @@ "execution_count": null, "id": "6e67e815", "metadata": {}, + "outputs": [], + "source": [ + "def get_customer_orders():\n", + " customer_orders = set() \n", + " seguir_comprando = input(\"¿Quieres comprar algo ? yes or no: \")\n", + " while seguir_comprando == \"yes\":\n", + " product = input(\"Introduce lo que vas a comprar: \")\n", + " customer_orders.add(product)\n", + " seguir_comprando = input(\"¿Quieres seguir comprando? yes or no: \")\n", + " \n", + " return customer_orders\n", + "\n", + "customer_orders = get_customer_orders()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "897f2a77", + "metadata": {}, + "outputs": [], + "source": [ + "def update_inventory(customer_order, inventory)\n", + " for i in customer_orders:\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "26a198c4", + "metadata": {}, + "outputs": [], + "source": [ + "def get_customer_orders():\n", + " customer_orders = set()\n", + " \n", + " product = input(\"Introduce el producto: \")\n", + " customer_orders.add(product)\n", + " \n", + " seguir_comprando = input(\"¿Quieres seguir comprando? yes or no: \")\n", + " \n", + " while seguir_comprando == \"yes\":\n", + " product = input(\"Introduce lo que vas a comprar: \")\n", + " customer_orders.add(product)\n", + " seguir_comprando = input(\"¿Quieres seguir comprando? yes or no: \")\n", + " \n", + " return customer_orders\n", + "\n", + "customer_orders = get_customer_orders()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4e3f22d4", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 64, + "id": "5352d84c", + "metadata": {}, "outputs": [ { - "ename": "SyntaxError", - "evalue": "expected ':' (4144453652.py, line 3)", - "output_type": "error", - "traceback": [ - " \u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[14]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[31m \u001b[39m\u001b[31mwhile continuar ==\"yes\"\u001b[39m\n ^\n\u001b[31mSyntaxError\u001b[39m\u001b[31m:\u001b[39m expected ':'\n" - ] + "data": { + "text/plain": [ + "['barcelona']" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" } ], - "source": [] + "source": [ + "newlistt" + ] }, { "cell_type": "code", "execution_count": null, - "id": "897f2a77", + "id": "c81012b7", "metadata": {}, "outputs": [], "source": [] From 03aa1cee8456972113de7adf93a1b8d0d7a5b2ac Mon Sep 17 00:00:00 2001 From: walnertpadron18 Date: Wed, 16 Sep 2026 11:19:48 +0100 Subject: [PATCH 3/3] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 126 ++++++++++++++++++++++++------------- 1 file changed, 84 insertions(+), 42 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 1577735..97bd9ff 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 10, "id": "dcc1c843", "metadata": {}, "outputs": [], @@ -65,94 +65,136 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 35, "id": "6e67e815", "metadata": {}, "outputs": [], "source": [ "def get_customer_orders():\n", " customer_orders = set() \n", - " seguir_comprando = input(\"¿Quieres comprar algo ? yes or no: \")\n", + " seguir_comprando = input(\"¿Quieres comprar algo ? yes or no: \").lower()\n", " while seguir_comprando == \"yes\":\n", " product = input(\"Introduce lo que vas a comprar: \")\n", " customer_orders.add(product)\n", - " seguir_comprando = input(\"¿Quieres seguir comprando? yes or no: \")\n", + " seguir_comprando = input(\"¿Quieres seguir comprando? yes or no: \").lower()\n", " \n", " return customer_orders\n", "\n", - "customer_orders = get_customer_orders()\n" + "\n" ] }, { "cell_type": "code", - "execution_count": null, - "id": "897f2a77", + "execution_count": 55, + "id": "26a198c4", "metadata": {}, "outputs": [], "source": [ - "def update_inventory(customer_order, inventory)\n", + "def update_inventory(customer_orders , inventory):\n", " for i in customer_orders:\n", - " \n" + " inventory[i] -= 1\n" ] }, { "cell_type": "code", - "execution_count": null, - "id": "26a198c4", + "execution_count": 62, + "id": "4f739ec5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "{'mug'}" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "def get_customer_orders():\n", - " customer_orders = set()\n", - " \n", - " product = input(\"Introduce el producto: \")\n", - " customer_orders.add(product)\n", - " \n", - " seguir_comprando = input(\"¿Quieres seguir comprando? yes or no: \")\n", - " \n", - " while seguir_comprando == \"yes\":\n", - " product = input(\"Introduce lo que vas a comprar: \")\n", - " customer_orders.add(product)\n", - " seguir_comprando = input(\"¿Quieres seguir comprando? yes or no: \")\n", - " \n", - " return customer_orders\n", - "\n", - "customer_orders = get_customer_orders()\n" + "customer_orders" ] }, { "cell_type": "code", - "execution_count": null, - "id": "4e3f22d4", + "execution_count": 63, + "id": "7f75a048", "metadata": {}, "outputs": [], - "source": [] + "source": [ + "def calculate_order_statistics(customer_orders, products):\n", + " order_statistics = len(customer_orders)\n", + " percentage_of_unique = (len(customer_orders) / len(products)) * 100\n", + " return order_statistics, percentage_of_unique\n" + ] }, { "cell_type": "code", "execution_count": 64, - "id": "5352d84c", + "id": "c4d479a9", + "metadata": {}, + "outputs": [], + "source": [ + "def print_order_statistics(order_statistics):\n", + " total_products_ordered, percentage_unique_products = order_statistics\n", + " print(f\"Total de productos pedidos: {total_products_ordered}\")\n", + " print(f\"Porcentaje de productos únicos pedidos: {percentage_unique_products}%\")\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "id": "f7d48533", + "metadata": {}, + "outputs": [], + "source": [ + "def print_updated_inventory(inventory):\n", + " for product, cantidad in inventory.items():\n", + " print(f\"{product}: {cantidad}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5a26c3e1", "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "['barcelona']" - ] - }, - "execution_count": 64, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "Total de productos pedidos: 2\n", + "Porcentaje de productos únicos pedidos: 40.0%\n", + "t-shirt: 50\n", + "mug: 39\n", + "hat: 50\n", + "book: 39\n", + "keychain: 30\n" + ] } ], "source": [ - "newlistt" + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "inventory = initialize_inventory(products)\n", + "\n", + "customer_orders = get_customer_orders()\n", + "\n", + "update_inventory(customer_orders, inventory)\n", + "\n", + "order_statistics = calculate_order_statistics(customer_orders, products)\n", + "\n", + "print_order_statistics(order_statistics)\n", + "\n", + "print_updated_inventory(inventory)" ] }, { "cell_type": "code", "execution_count": null, - "id": "c81012b7", + "id": "b06543eb", "metadata": {}, "outputs": [], "source": []