From fd997a646fef52645ab370405cf4e8cd22108aca Mon Sep 17 00:00:00 2001 From: demonvaa Date: Tue, 14 Apr 2026 13:56:17 +0200 Subject: [PATCH 1/4] Update lab-python-flow-control.ipynb Resolucion 14042026 13:56 --- lab-python-flow-control.ipynb | 54 +++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..fd4943d 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,11 +37,61 @@ "\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": 10, + "id": "e13eaab3", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 10, 'mug': 10, 'hat': 10, 'book': 10, 'keychain': 10}\n", + "\n", + "customer_orders are {'mug', 'hat'}\n", + "el inventario despues de quitar esos objetos queda {'t-shirt': 10, 'mug': 9, 'hat': 9, 'book': 10, 'keychain': 10}\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "\n", + "\"\"\" Le añado cantidades\"\"\"\n", + "for x in products:\n", + " cantidad = int(input(f\"Quantity of {x}\" ))\n", + " inventory[x] = cantidad\n", + "print(inventory)\n", + "\n", + "\"\"\" Creo las ordenes que voy a pedir hasta que me digan si o no\"\"\"\n", + "customer_orders = set()\n", + "print(type(customer_orders))\n", + "\n", + "another_product = \"yes\"\n", + "\n", + "while another_product == 'yes':\n", + " customer_orders.add (input(\"Escoge un producto para añadir\"))\n", + " another_product = input(\"Do you want to add another product (yes/no)\").lower()\n", + "\n", + "\"\"\" Imprimo las ordenes de cliente que van a pedir \"\"\"\n", + "print(f\"customer_orders are {customer_orders}\")\n", + "\n", + "\"\"\" Resto 1 cantidad solo a esas ordenes en el inventario\"\"\" # como es set solo me resta una de esas\n", + "\n", + "for x in customer_orders:\n", + " inventory[x] -=1\n", + "\n", + "\"\"\" Copruebo como ha cambiado el inventario\n", + "\"\"\"\n", + "print(f\"el inventario despues de quitar esos objetos queda {inventory}\")" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -55,7 +105,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.2" } }, "nbformat": 4, From 4e8fd44e34bc830c644c5494cdddbf6b1fcbd777 Mon Sep 17 00:00:00 2001 From: demonvaa Date: Fri, 17 Apr 2026 13:35:06 +0200 Subject: [PATCH 2/4] Update lab-python-flow-control.ipynb Modifique linea if x in inventory --- lab-python-flow-control.ipynb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index fd4943d..381869f 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "id": "e13eaab3", "metadata": {}, "outputs": [ @@ -59,7 +59,7 @@ "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", "inventory = {}\n", "\n", - "\"\"\" Le añado cantidades\"\"\"\n", + "\"\"\" Le añado cantidades \"\"\"\n", "for x in products:\n", " cantidad = int(input(f\"Quantity of {x}\" ))\n", " inventory[x] = cantidad\n", From b6f3e787514986058b0ad6101099f837e3c7fbfc Mon Sep 17 00:00:00 2001 From: demonvaa Date: Fri, 17 Apr 2026 14:09:47 +0200 Subject: [PATCH 3/4] Update lab-python-flow-control.ipynb Change if inventory[x] --- lab-python-flow-control.ipynb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 381869f..6b25670 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -81,7 +81,8 @@ "\"\"\" Resto 1 cantidad solo a esas ordenes en el inventario\"\"\" # como es set solo me resta una de esas\n", "\n", "for x in customer_orders:\n", - " inventory[x] -=1\n", + " if x in inventory:\n", + " inventory[x] -=1\n", "\n", "\"\"\" Copruebo como ha cambiado el inventario\n", "\"\"\"\n", From 0f2a25e59f51e745f2bb0f2504578d807e043830 Mon Sep 17 00:00:00 2001 From: demonvaa Date: Fri, 17 Apr 2026 16:17:33 +0200 Subject: [PATCH 4/4] Modificacion 14/04/2026 --- lab-python-flow-control.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 6b25670..09208e1 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -73,16 +73,16 @@ "\n", "while another_product == 'yes':\n", " customer_orders.add (input(\"Escoge un producto para añadir\"))\n", - " another_product = input(\"Do you want to add another product (yes/no)\").lower()\n", + " another_product = input(\"Do you want to add another product (yes/no)\").strip.lower()\n", "\n", "\"\"\" Imprimo las ordenes de cliente que van a pedir \"\"\"\n", "print(f\"customer_orders are {customer_orders}\")\n", "\n", "\"\"\" Resto 1 cantidad solo a esas ordenes en el inventario\"\"\" # como es set solo me resta una de esas\n", "\n", - "for x in customer_orders:\n", - " if x in inventory:\n", - " inventory[x] -=1\n", + "for product in customer_orders:\n", + " if product in inventory:\n", + " inventory[product] -=1\n", "\n", "\"\"\" Copruebo como ha cambiado el inventario\n", "\"\"\"\n",