From 641ed2e6ec8b12977848c256a3cb0a1c4c123db9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 15:45:01 +0200 Subject: [PATCH 1/5] Update lab-python-data-structures.ipynb Test lab structures --- lab-python-data-structures.ipynb | 70 ++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..79fa48ff 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -13,7 +13,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Exercise: Managing Customer Orders\n", + "## Exercise: Managing Customer Orders\n", "\n", "As part of a business venture, you are starting an online store that sells various products. To ensure smooth operations, you need to develop a program that manages customer orders and inventory.\n", "\n", @@ -50,11 +50,75 @@ "\n", "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The customer has ordered {'mug', 'hat', 'book'}\n", + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered:60.000000% \n" + ] + }, + { + "ename": "ValueError", + "evalue": "too many values to unpack (expected 2)", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[27]\u001b[39m\u001b[32m, line 26\u001b[39m\n\u001b[32m 22\u001b[39m \n\u001b[32m 23\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m order \u001b[38;5;28;01min\u001b[39;00m customers_orders:\n\u001b[32m 24\u001b[39m inventory[order] -= \u001b[32m1\u001b[39m\n\u001b[32m 25\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m26\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m key, value \u001b[38;5;28;01min\u001b[39;00m inventory:\n\u001b[32m 27\u001b[39m print (key, value)\n", + "\u001b[31mValueError\u001b[39m: too many values to unpack (expected 2)" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "for product in products:\n", + " quantity = int(input(f\"Enter quantity of {product}: \"))\n", + " inventory[product] = quantity\n", + "\n", + "customers_orders = set()\n", + "for i in range (3):\n", + " order = input('Enter the name of three products. Choose between \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\": ')\n", + " customers_orders.add(order)\n", + "\n", + "print (f\"The customer has ordered {customers_orders}\")\n", + "\n", + "total_products_ordered = len(customers_orders)\n", + "percentage_ordered = (total_products_ordered/sum((inventory.values())))\n", + "\n", + "order_status = (total_products_ordered, percentage_products_ordered)\n", + "\n", + "print (\"Order Statistics:\" \"\\n\"\n", + "f\"Total Products Ordered: {total_products_ordered}\" \"\\n\"\n", + "f\"Percentage of Products Ordered:{percentage_ordered:%} \")\n", + "\n", + "for order in customers_orders: \n", + " inventory[order] -= 1\n", + "\n", + "for key, value in inventory.items():\n", + " print (key, value)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "venv-bootcamp (3.14.3)", "language": "python", "name": "python3" }, @@ -68,7 +132,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.3" } }, "nbformat": 4, From 31a7d0171219040911d92ae1e539967d50bd452c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 16:05:57 +0200 Subject: [PATCH 2/5] Update lab-python-data-structures.ipynb Fix name variables and calculations --- lab-python-data-structures.ipynb | 40 ++++++++++++++------------------ 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 79fa48ff..958a2bd3 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -63,18 +63,12 @@ "The customer has ordered {'mug', 'hat', 'book'}\n", "Order Statistics:\n", "Total Products Ordered: 3\n", - "Percentage of Products Ordered:60.000000% \n" - ] - }, - { - "ename": "ValueError", - "evalue": "too many values to unpack (expected 2)", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[27]\u001b[39m\u001b[32m, line 26\u001b[39m\n\u001b[32m 22\u001b[39m \n\u001b[32m 23\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m order \u001b[38;5;28;01min\u001b[39;00m customers_orders:\n\u001b[32m 24\u001b[39m inventory[order] -= \u001b[32m1\u001b[39m\n\u001b[32m 25\u001b[39m \n\u001b[32m---> \u001b[39m\u001b[32m26\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m key, value \u001b[38;5;28;01min\u001b[39;00m inventory:\n\u001b[32m 27\u001b[39m print (key, value)\n", - "\u001b[31mValueError\u001b[39m: too many values to unpack (expected 2)" + "Percentage of Products Ordered:60.0% \n", + "The actual quantity of item t-shirt is: 1\n", + "The actual quantity of item mug is: 0\n", + "The actual quantity of item hat is: 0\n", + "The actual quantity of item book is: 0\n", + "The actual quantity of item keychain is: 1\n" ] } ], @@ -85,27 +79,27 @@ " quantity = int(input(f\"Enter quantity of {product}: \"))\n", " inventory[product] = quantity\n", "\n", - "customers_orders = set()\n", + "customer_orders = set()\n", "for i in range (3):\n", " order = input('Enter the name of three products. Choose between \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\": ')\n", - " customers_orders.add(order)\n", + " customer_orders.add(order)\n", "\n", - "print (f\"The customer has ordered {customers_orders}\")\n", + "print (f\"The customer has ordered {customer_orders}\")\n", "\n", - "total_products_ordered = len(customers_orders)\n", - "percentage_ordered = (total_products_ordered/sum((inventory.values())))\n", + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = (total_products_ordered/sum((inventory.values())))*100\n", "\n", - "order_status = (total_products_ordered, percentage_products_ordered)\n", + "order_status = (total_products_ordered, percentage_ordered)\n", "\n", "print (\"Order Statistics:\" \"\\n\"\n", "f\"Total Products Ordered: {total_products_ordered}\" \"\\n\"\n", - "f\"Percentage of Products Ordered:{percentage_ordered:%} \")\n", + "f\"Percentage of Products Ordered:{percentage_ordered}% \")\n", "\n", - "for order in customers_orders: \n", + "for order in customer_orders: \n", " inventory[order] -= 1\n", "\n", - "for key, value in inventory.items():\n", - " print (key, value)" + "for key,value in inventory.items():\n", + " print (f\"The actual quantity of item {key} is: {value}\")" ] }, { From fd7248dd56ba89b184ee72726216ef802b44d25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 16:35:40 +0200 Subject: [PATCH 3/5] Update lab-python-data-structures.ipynb correct 'percentage_ordered' formula and add inventory notification --- lab-python-data-structures.ipynb | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 958a2bd3..2527bc32 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,21 +53,23 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": null, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The customer has ordered {'mug', 'hat', 'book'}\n", + "The customer has ordered {'mug', 'hat', 'bok'}\n", + "\n", "Order Statistics:\n", - "Total Products Ordered: 3\n", - "Percentage of Products Ordered:60.0% \n", + " Total Products Ordered: 3\n", + " Percentage of Products Ordered:60.0%\n", + "\n", "The actual quantity of item t-shirt is: 1\n", "The actual quantity of item mug is: 0\n", "The actual quantity of item hat is: 0\n", - "The actual quantity of item book is: 0\n", + "The actual quantity of item book is: 1\n", "The actual quantity of item keychain is: 1\n" ] } @@ -82,21 +84,23 @@ "customer_orders = set()\n", "for i in range (3):\n", " order = input('Enter the name of three products. Choose between \"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\": ')\n", - " customer_orders.add(order)\n", + " if order in products:\n", + " customer_orders.add(order)\n", "\n", - "print (f\"The customer has ordered {customer_orders}\")\n", + "print (f\"The customer has ordered {customer_orders}\" \"\\n\")\n", "\n", "total_products_ordered = len(customer_orders)\n", - "percentage_ordered = (total_products_ordered/sum((inventory.values())))*100\n", + "percentage_ordered = (total_products_ordered/len(products))*100\n", "\n", "order_status = (total_products_ordered, percentage_ordered)\n", "\n", - "print (\"Order Statistics:\" \"\\n\"\n", - "f\"Total Products Ordered: {total_products_ordered}\" \"\\n\"\n", - "f\"Percentage of Products Ordered:{percentage_ordered}% \")\n", + "print (\"Order Statistics:\" \"\\n\", \n", + "f\"Total Products Ordered: {total_products_ordered}\" \"\\n\",\n", + "f\"Percentage of Products Ordered:{percentage_ordered}%\" \"\\n\")\n", "\n", - "for order in customer_orders: \n", - " inventory[order] -= 1\n", + "for order in customer_orders:\n", + " if order in products:\n", + " inventory[order] -= 1\n", "\n", "for key,value in inventory.items():\n", " print (f\"The actual quantity of item {key} is: {value}\")" From 02701888fa4b248bd74e3f8c8eab7e106dfbc004 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 16:43:53 +0200 Subject: [PATCH 4/5] Update lab-python-data-structures.ipynb correct format output --- lab-python-data-structures.ipynb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 2527bc32..5999d69b 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,23 +53,23 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "The customer has ordered {'mug', 'hat', 'bok'}\n", + "The customer has ordered {'mug', 'hat', 'book'}\n", "\n", "Order Statistics:\n", - " Total Products Ordered: 3\n", - " Percentage of Products Ordered:60.0%\n", + " Total Products Ordered: <3>\n", + " Percentage of Products Ordered: <60.0>%\n", "\n", "The actual quantity of item t-shirt is: 1\n", "The actual quantity of item mug is: 0\n", "The actual quantity of item hat is: 0\n", - "The actual quantity of item book is: 1\n", + "The actual quantity of item book is: 0\n", "The actual quantity of item keychain is: 1\n" ] } @@ -95,8 +95,8 @@ "order_status = (total_products_ordered, percentage_ordered)\n", "\n", "print (\"Order Statistics:\" \"\\n\", \n", - "f\"Total Products Ordered: {total_products_ordered}\" \"\\n\",\n", - "f\"Percentage of Products Ordered:{percentage_ordered}%\" \"\\n\")\n", + "f\"Total Products Ordered: <{total_products_ordered}>\" \"\\n\",\n", + "f\"Percentage of Products Ordered: <{percentage_ordered}>%\" \"\\n\")\n", "\n", "for order in customer_orders:\n", " if order in products:\n", From 468868915943abdad84260d7aabbd784cc371ccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Marqu=C3=A9s=20Cabedo?= Date: Mon, 13 Apr 2026 16:49:57 +0200 Subject: [PATCH 5/5] Update lab-python-data-structures.ipynb change format output --- lab-python-data-structures.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5999d69b..d4821040 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -95,8 +95,8 @@ "order_status = (total_products_ordered, percentage_ordered)\n", "\n", "print (\"Order Statistics:\" \"\\n\", \n", - "f\"Total Products Ordered: <{total_products_ordered}>\" \"\\n\",\n", - "f\"Percentage of Products Ordered: <{percentage_ordered}>%\" \"\\n\")\n", + "f\"Total Products Ordered: {total_products_ordered}\" \"\\n\",\n", + "f\"Percentage of Products Ordered: {percentage_ordered}%\" \"\\n\")\n", "\n", "for order in customer_orders:\n", " if order in products:\n",