From d56cbacc742d4d3e8472769b1317bbf4b373e159 Mon Sep 17 00:00:00 2001 From: Eduardo Romero Date: Tue, 14 Oct 2025 20:28:19 +0200 Subject: [PATCH 1/2] edu19 --- lab-python-data-structures.ipynb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..472c05ed 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +50,19 @@ "\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": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "edu" + ] } ], "metadata": { From f6cc2ad2f83fa24da2c5d031e6953301972f0725 Mon Sep 17 00:00:00 2001 From: Eduardo Romero Date: Thu, 13 Nov 2025 17:14:25 +0100 Subject: [PATCH 2/2] =?UTF-8?q?Actualizaci=C3=B3n=20del=20notebook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab-python-data-structures.ipynb | 159 +++++++++++++++++++++++++++++-- 1 file changed, 151 insertions(+), 8 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 472c05ed..02a9b8b3 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,21 +53,164 @@ }, { "cell_type": "code", - "execution_count": null, - "metadata": { - "vscode": { - "languageId": "plaintext" + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "# Step 1: Define the list of products\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "# Step 2: Create an inventory with predefined quantities\n", + "inventory = {\n", + " \"t-shirt\": 5,\n", + " \"mug\": 3,\n", + " \"hat\": 2,\n", + " \"book\": 4,\n", + " \"keychain\": 6\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "# Step 3: Create an empty set for customer orders\n", + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [], + "source": [ + "# Step 4: Simulate user selecting three products\n", + "selected_orders = [\"mug\", \"book\", \"hat\"] # puedes cambiar estos valores\n", + "for order in selected_orders:\n", + " if order in products:\n", + " customer_orders.add(order)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Customer Orders:\n", + "- hat\n", + "- mug\n", + "- book\n" + ] } - }, + ], + "source": [ + "# Step 5: Print customer orders\n", + "print(\"\\nCustomer Orders:\")\n", + "for item in customer_orders:\n", + " print(\"-\", item)" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, "outputs": [], "source": [ - "edu" + "\n", + "# Step 6: Calculate order statistics\n", + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = (total_products_ordered / len(products)) * 100" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": {}, + "outputs": [], + "source": [ + "# Step 7: Store statistics in a tuple\n", + "order_status = (total_products_ordered, percentage_ordered)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.00%\n" + ] + } + ], + "source": [ + "# Step 8: Print order statistics\n", + "print(\"\\nOrder Statistics:\")\n", + "print(\"Total Products Ordered:\", order_status[0])\n", + "print(f\"Percentage of Products Ordered: {order_status[1]:.2f}%\")" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "# Step 9: Update inventory (subtract 1 for each ordered product)\n", + "for item in customer_orders:\n", + " if inventory[item] > 0:\n", + " inventory[item] -= 1" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Updated Inventory:\n", + "t-shirt: 5\n", + "mug: 2\n", + "hat: 1\n", + "book: 3\n", + "keychain: 6\n" + ] + } + ], + "source": [ + "# Step 10: Print updated inventory\n", + "print(\"\\nUpdated Inventory:\")\n", + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\")" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -81,7 +224,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.9" } }, "nbformat": 4,