From 73439da24ccfaf3a30d542f9e33a12e241d0a3ee Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Tue, 14 Apr 2026 14:55:54 +0200 Subject: [PATCH 1/3] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 49 +++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..47e51b5 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,11 +37,56 @@ "\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": "68d0b580", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 5, 'mug': 7, 'hat': 2, 'book': 9, 'keychain': 1}\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "\n", + "for item in products:\n", + " quantity = int(input(f\"Enter the quantity of {item} in inventory: \"))\n", + " inventory[item] = quantity\n", + "\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1f467e6f", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = set()\n", + "\n", + "continue_entering = 'yes'\n", + "while continue_entering.lower() == 'yes':\n", + " order = input(\"Enter a product to order (or type 'done' to finish): \")\n", + " if order.lower() == 'done':\n", + " break\n", + " elif order in products:\n", + " customer_orders.add(order)\n", + " else:\n", + " print(\"Product not found. Please enter a valid product.\") " + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -55,7 +100,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.4" } }, "nbformat": 4, From b4834787f1649ab5e6aac1a133f92ee2e953ba58 Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Tue, 14 Apr 2026 16:12:17 +0200 Subject: [PATCH 2/3] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 56 ++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 11 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 47e51b5..f7b67ce 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": 7, "id": "68d0b580", "metadata": {}, "outputs": [ @@ -48,7 +48,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'t-shirt': 5, 'mug': 7, 'hat': 2, 'book': 9, 'keychain': 1}\n" + "{'t-shirt': 5, 'mug': 8, 'hat': 3, 'book': 12, 'keychain': 7}\n" ] } ], @@ -65,22 +65,56 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "id": "1f467e6f", "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'book', 'keychain', 'mug'}\n" + ] + } + ], "source": [ "customer_orders = set()\n", "\n", "continue_entering = 'yes'\n", "while continue_entering.lower() == 'yes':\n", - " order = input(\"Enter a product to order (or type 'done' to finish): \")\n", - " if order.lower() == 'done':\n", - " break\n", - " elif order in products:\n", - " customer_orders.add(order)\n", - " else:\n", - " print(\"Product not found. Please enter a valid product.\") " + " product_order = input('Enter the product you want to order: ')\n", + " customer_orders.add(product_order)\n", + "\n", + " continue_entering = input('Do you want to add another product?').lower()\n", + "\n", + "print(customer_orders)\n", + " \n", + "\n", + "\n", + "\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "1d068c62", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 5, 'mug': 7, 'hat': 3, 'book': 11, 'keychain': 6}\n" + ] + } + ], + "source": [ + "for item in inventory:\n", + " if item in customer_orders:\n", + " inventory[item] -=1\n", + "\n", + "print(inventory)" ] } ], From 293c73b6d2584e51f3a19e39b74ca2c35815af0f Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Tue, 14 Apr 2026 16:26:14 +0200 Subject: [PATCH 3/3] Update lab-python-flow-control.ipynb --- lab-python-flow-control.ipynb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f7b67ce..c74710d 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "id": "1f467e6f", "metadata": {}, "outputs": [ @@ -85,14 +85,9 @@ " product_order = input('Enter the product you want to order: ')\n", " customer_orders.add(product_order)\n", "\n", - " continue_entering = input('Do you want to add another product?').lower()\n", + " continue_entering = input('Do you want to add another product? (yes/no)').lower()\n", "\n", - "print(customer_orders)\n", - " \n", - "\n", - "\n", - "\n", - " " + "print(customer_orders) " ] }, {