From 4fcd7bb31733f69a70b1d9ea024deb162713ba8f Mon Sep 17 00:00:00 2001 From: arnaumatasfont-keky Date: Mon, 13 Apr 2026 15:44:54 +0200 Subject: [PATCH 1/2] Update lab-python-data-structures.ipynb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Realización de ejercicios. --- lab-python-data-structures.ipynb | 157 ++++++++++++++++++++++++++++++- 1 file changed, 155 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..3ae8e7b4 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,164 @@ "\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": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n" + ] + } + ], + "source": [ + "# Step 1: Define the products list\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "print(products)" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 2, 'mug': 4, 'hat': 3, 'book': 5, 'keychain': 1}\n" + ] + } + ], + "source": [ + "quantity0 = int(input(f\"Enter the quantity for {products[0]}: \"))\n", + "inventory[products[0]] = quantity0\n", + "quantity1 = int(input(f\"Enter the quantity for {products[1]}: \"))\n", + "inventory[products[1]] = quantity1\n", + "quantity2 = int(input(f\"Enter the quantity for {products[2]}: \"))\n", + "inventory[products[2]] = quantity2\n", + "quantity3 = int(input(f\"Enter the quantity for {products[3]}: \"))\n", + "inventory[products[3]] = quantity3\n", + "quantity4 = int(input(f\"Enter the quantity for {products[4]}: \"))\n", + "inventory[products[4]] = quantity4\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "customers_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "product1 = input(f\"Enter a name for the first product from {products}: \")\n", + "customers_orders.add(product1)\n", + "product2 = input(f\"Enter a name for the second product from {products}: \")\n", + "customers_orders.add(product2)\n", + "product3 = input(f\"Enter a name for the third product from {products}: \")\n", + "customers_orders.add(product3)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt', 'book', 'hat'}\n" + ] + } + ], + "source": [ + "print(customers_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total products ordered: 3\n", + "Percentage of products ordered: 60.00%\n", + "(3, 60.0)\n" + ] + } + ], + "source": [ + "total_products_ordered = len(customers_orders)\n", + "print(f\"Total products ordered: {total_products_ordered}\")\n", + "\n", + "percentage_orders = (total_products_ordered / len(products)) * 100\n", + "print(f\"Percentage of products ordered: {percentage_orders:.2f}%\")\n", + "\n", + "order_status = (total_products_ordered, percentage_orders)\n", + "print(order_status)" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Inventory after updating for customer orders:\n", + "T-shirt: 1\n", + "Mug: 4\n", + "Hat: 2\n", + "Book: 4\n", + "Keychain: 1\n" + ] + } + ], + "source": [ + "inventory[products[0]] -= 1\n", + "inventory[products[2]] -= 1\n", + "inventory[products[3]] -= 1\n", + "\n", + "print(\"\\nInventory after updating for customer orders:\")\n", + "print(f\"T-shirt: {inventory[products[0]]}\")\n", + "print(f\"Mug: {inventory[products[1]]}\")\n", + "print(f\"Hat: {inventory[products[2]]}\")\n", + "print(f\"Book: {inventory[products[3]]}\")\n", + "print(f\"Keychain: {inventory[products[4]]}\")" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv", "language": "python", "name": "python3" }, @@ -68,7 +221,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.3" } }, "nbformat": 4, From 313c9a592d4da6b0d8ed8cf2ae9498b6b2080509 Mon Sep 17 00:00:00 2001 From: arnaumatasfont-keky Date: Mon, 13 Apr 2026 15:54:53 +0200 Subject: [PATCH 2/2] Update lab-python-data-structures.ipynb para repetir la pull request --- lab-python-data-structures.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 3ae8e7b4..12693b2a 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -174,7 +174,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 15, "metadata": {}, "outputs": [ {