From f55d67d42acea3fe863563a53c528e7077145c35 Mon Sep 17 00:00:00 2001 From: walnertpadron18 Date: Tue, 15 Sep 2026 13:47:25 +0100 Subject: [PATCH 1/5] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 118 +++++++++++++++++++++++++++++++++- 1 file changed, 116 insertions(+), 2 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..b832c1b 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,11 +37,125 @@ "\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": 1, + "id": "5b52af72", + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "7d93b074", + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "id": "819e0924", + "metadata": {}, + "outputs": [], + "source": [ + "for i in products:\n", + " inventory[i] = int(input(f\"Cuantas unidades necesita de {i}? \"))\n" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "1ffaf70b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 37, 'mug': 47, 'hat': 30, 'book': 44, 'keychain': 40}" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "customer_orders = set()\n", + "for i in range(3):\n", + " product = input(f\"Ingrese el articulo {i + 1}: \")\n", + " if product in inventory:\n", + " inventory[product] -= 1\n", + " customer_orders.add(product)\n", + " else:\n", + " print(f\"'{product}' no está en el inventario.\")\n", + "inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "id": "ce02d88b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Gracias por su compra\n" + ] + } + ], + "source": [ + "continuar = \"yes\"\n", + "while continuar == \"yes\":\n", + " continuar = input(\"¿Quieres introducir otro articulo? (yes/no): \")\n", + " if continuar == \"yes\":\n", + " product = input(f\"Ingrese el articulo: \")\n", + " inventory[product] -= 1\n", + " customer_orders.add(product)\n", + " else:\n", + " print(\"Gracias por su compra\")" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "id": "9d9541ca", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'book', 'mug', 't-shirt', 'hat'}\n", + "{'t-shirt': 37, 'mug': 47, 'hat': 29, 'book': 43, 'keychain': 40}\n" + ] + } + ], + "source": [ + "print(customer_orders)\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e5c6f70b", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -55,7 +169,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.7" } }, "nbformat": 4, From c184dac5db21d17757e0afd5ebae1bf8bf689442 Mon Sep 17 00:00:00 2001 From: walnertpadron18 Date: Tue, 15 Sep 2026 14:11:54 +0100 Subject: [PATCH 2/5] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 45 ++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index b832c1b..5e91927 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": 6, "id": "5b52af72", "metadata": {}, "outputs": [], @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 7, "id": "7d93b074", "metadata": {}, "outputs": [], @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 8, "id": "819e0924", "metadata": {}, "outputs": [], @@ -71,17 +71,17 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 40, "id": "1ffaf70b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'t-shirt': 37, 'mug': 47, 'hat': 30, 'book': 44, 'keychain': 40}" + "{'t-shirt': 29, 'mug': 34, 'hat': 47, 'book': 22, 'keychain': 20}" ] }, - "execution_count": 53, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -95,12 +95,35 @@ " customer_orders.add(product)\n", " else:\n", " print(f\"'{product}' no está en el inventario.\")\n", - "inventory" + "inventory\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "282564f6", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'book', 'mug', 't-shirt'}" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "customer_orders" ] }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 42, "id": "ce02d88b", "metadata": {}, "outputs": [ @@ -126,7 +149,7 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 43, "id": "9d9541ca", "metadata": {}, "outputs": [ @@ -134,8 +157,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'book', 'mug', 't-shirt', 'hat'}\n", - "{'t-shirt': 37, 'mug': 47, 'hat': 29, 'book': 43, 'keychain': 40}\n" + "{'book', 'hat', 't-shirt', 'mug'}\n", + "{'t-shirt': 29, 'mug': 34, 'hat': 46, 'book': 22, 'keychain': 20}\n" ] } ], From 337eb8bde6dc0a0108ad2285965487c2262652c3 Mon Sep 17 00:00:00 2001 From: walnertpadron18 Date: Tue, 15 Sep 2026 14:32:32 +0100 Subject: [PATCH 3/5] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 5e91927..6067193 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -71,7 +71,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": null, "id": "1ffaf70b", "metadata": {}, "outputs": [ @@ -95,9 +95,7 @@ " customer_orders.add(product)\n", " else:\n", " print(f\"'{product}' no está en el inventario.\")\n", - "inventory\n", - "\n", - "\n" + "inventory" ] }, { @@ -123,7 +121,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 55, "id": "ce02d88b", "metadata": {}, "outputs": [ @@ -131,6 +129,7 @@ "name": "stdout", "output_type": "stream", "text": [ + "El articulo no se encuentra en el inventario\n", "Gracias por su compra\n" ] } @@ -138,18 +137,21 @@ "source": [ "continuar = \"yes\"\n", "while continuar == \"yes\":\n", - " continuar = input(\"¿Quieres introducir otro articulo? (yes/no): \")\n", + " continuar = input(\"¿Quieres introducir otro articulo? (yes/no): \").lower()\n", " if continuar == \"yes\":\n", " product = input(f\"Ingrese el articulo: \")\n", - " inventory[product] -= 1\n", - " customer_orders.add(product)\n", + " if product in inventory:\n", + " inventory[product] -= 1\n", + " customer_orders.add(product)\n", + " else:\n", + " print(\"El articulo no se encuentra en el inventario\")\n", " else:\n", - " print(\"Gracias por su compra\")" + " print(\"Gracias por su compra\")" ] }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 50, "id": "9d9541ca", "metadata": {}, "outputs": [ @@ -158,7 +160,7 @@ "output_type": "stream", "text": [ "{'book', 'hat', 't-shirt', 'mug'}\n", - "{'t-shirt': 29, 'mug': 34, 'hat': 46, 'book': 22, 'keychain': 20}\n" + "{'t-shirt': 29, 'mug': 34, 'hat': 46, 'book': 20, 'keychain': 20}\n" ] } ], From 68be91dd536e2d579acfe4cc8fd95f9c5374b497 Mon Sep 17 00:00:00 2001 From: walnertpadron18 Date: Tue, 15 Sep 2026 14:46:24 +0100 Subject: [PATCH 4/5] new wa --- .vscode/settings.json | 3 ++ lab-python-flow-control.ipynb | 71 ++++++++++------------------------- 2 files changed, 22 insertions(+), 52 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..642ff51 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.REPL.enableREPLSmartSend": false +} \ No newline at end of file diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 6067193..9ac10c6 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 67, "id": "5b52af72", "metadata": {}, "outputs": [], @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 68, "id": "7d93b074", "metadata": {}, "outputs": [], @@ -60,68 +60,36 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "819e0924", + "execution_count": 70, + "id": "b3aa0754", "metadata": {}, "outputs": [], "source": [ "for i in products:\n", - " inventory[i] = int(input(f\"Cuantas unidades necesita de {i}? \"))\n" + " inventory[i] = int(input(f\"Cuantas unidades necesita de {i}? \"))" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 71, "id": "1ffaf70b", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'t-shirt': 29, 'mug': 34, 'hat': 47, 'book': 22, 'keychain': 20}" - ] - }, - "execution_count": 40, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "customer_orders = set()\n", - "for i in range(3):\n", - " product = input(f\"Ingrese el articulo {i + 1}: \")\n", - " if product in inventory:\n", - " inventory[product] -= 1\n", - " customer_orders.add(product)\n", - " else:\n", - " print(f\"'{product}' no está en el inventario.\")\n", - "inventory" + "customer_orders = set()" ] }, { "cell_type": "code", - "execution_count": 41, - "id": "282564f6", + "execution_count": null, + "id": "2de894df", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'book', 'mug', 't-shirt'}" - ] - }, - "execution_count": 41, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "customer_orders" - ] + "outputs": [], + "source": [] }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 72, "id": "ce02d88b", "metadata": {}, "outputs": [ @@ -129,7 +97,6 @@ "name": "stdout", "output_type": "stream", "text": [ - "El articulo no se encuentra en el inventario\n", "Gracias por su compra\n" ] } @@ -137,21 +104,21 @@ "source": [ "continuar = \"yes\"\n", "while continuar == \"yes\":\n", - " continuar = input(\"¿Quieres introducir otro articulo? (yes/no): \").lower()\n", + " continuar = input(\"¿Quieres comprar un articulo? (yes/no): \").lower()\n", " if continuar == \"yes\":\n", - " product = input(f\"Ingrese el articulo: \")\n", + " product = input(\"Ingrese el articulo: \")\n", " if product in inventory:\n", " inventory[product] -= 1\n", " customer_orders.add(product)\n", " else:\n", - " print(\"El articulo no se encuentra en el inventario\")\n", + " print(\"Ese artículo no está en el inventario.\")\n", " else:\n", " print(\"Gracias por su compra\")" ] }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 73, "id": "9d9541ca", "metadata": {}, "outputs": [ @@ -159,8 +126,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'book', 'hat', 't-shirt', 'mug'}\n", - "{'t-shirt': 29, 'mug': 34, 'hat': 46, 'book': 20, 'keychain': 20}\n" + "{'book'}\n", + "{'t-shirt': 40, 'mug': 50, 'hat': 60, 'book': 29, 'keychain': 40}\n" ] } ], From 3249a47c8db3188da822db4d8340ad3cb6edd576 Mon Sep 17 00:00:00 2001 From: walnertpadron18 Date: Tue, 15 Sep 2026 14:57:03 +0100 Subject: [PATCH 5/5] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 9ac10c6..234c38d 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -40,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 1, "id": "5b52af72", "metadata": {}, "outputs": [], @@ -50,7 +50,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 2, "id": "7d93b074", "metadata": {}, "outputs": [], @@ -60,7 +60,7 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 11, "id": "b3aa0754", "metadata": {}, "outputs": [], @@ -71,7 +71,7 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 4, "id": "1ffaf70b", "metadata": {}, "outputs": [], @@ -81,15 +81,7 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "2de894df", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 72, + "execution_count": 12, "id": "ce02d88b", "metadata": {}, "outputs": [ @@ -108,7 +100,6 @@ " if continuar == \"yes\":\n", " product = input(\"Ingrese el articulo: \")\n", " if product in inventory:\n", - " inventory[product] -= 1\n", " customer_orders.add(product)\n", " else:\n", " print(\"Ese artículo no está en el inventario.\")\n", @@ -118,7 +109,7 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 14, "id": "9d9541ca", "metadata": {}, "outputs": [ @@ -126,12 +117,14 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'book'}\n", - "{'t-shirt': 40, 'mug': 50, 'hat': 60, 'book': 29, 'keychain': 40}\n" + "{'mug', 'hat', 'book'}\n", + "{'t-shirt': 10, 'mug': 9, 'hat': 9, 'book': 9, 'keychain': 10}\n" ] } ], "source": [ + "for product in customer_orders:\n", + " inventory[product] -= 1\n", "print(customer_orders)\n", "print(inventory)" ]