diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..d082a313 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,89 @@ "\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": [ + "{'book', 'mug', 'hat'}\n", + "Order Statistics:\n", + "Total products ordered: 3\n", + "Percentage of products ordered: 60.0 %\n", + "\n", + "Updated inventory:\n", + "t-shirt: 1\n", + "mug: 3\n", + "hat: 5\n", + "book: 7\n", + "keychain: 9\n" + ] + } + ], + "source": [ + "# 1\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "# 2\n", + "inventory = {}\n", + "# 3\n", + "inventory[\"t-shirt\"] = int(input(\"Cantidad t-shirt: \"))\n", + "inventory[\"mug\"] = int(input(\"Cantidad mug: \"))\n", + "inventory[\"hat\"] = int(input(\"Cantidad hat: \"))\n", + "inventory[\"book\"] = int(input(\"Cantidad book: \"))\n", + "inventory[\"keychain\"] = int(input(\"Cantidad keychain: \"))\n", + "# 4\n", + "customer_orders = set ()\n", + "# 5\n", + "order1 = input(\"Type product 1: \")\n", + "customer_orders.add(order1)\n", + "\n", + "order2 = input(\"Type product 2: \")\n", + "customer_orders.add(order2)\n", + "\n", + "order3 = input(\"Type product 3: \")\n", + "customer_orders.add(order3)\n", + "\n", + "# 6\n", + "print (customer_orders)\n", + "\n", + "# 7\n", + "total = len (customer_orders)\n", + "percentage = (total / len(products)) * 100\n", + "order_status = (total, percentage)\n", + "\n", + "# 8 \n", + "print(\"Order Statistics:\")\n", + "print(\"Total products ordered:\", total)\n", + "print(\"Percentage of products ordered:\", percentage, \"%\")\n", + "\n", + "# 9 \n", + "inventory[\"t-shirt\"] -= 1\n", + "inventory[\"mug\"] -= 1\n", + "inventory[\"hat\"] -= 1\n", + "inventory[\"book\"] -= 1\n", + "inventory[\"keychain\"] -= 1\n", + "\n", + "# 10\n", + "print()\n", + "print(\"Updated inventory list:\")\n", + "\n", + "print(\"t-shirt:\", inventory[\"t-shirt\"])\n", + "print(\"mug:\", inventory[\"mug\"])\n", + "print(\"hat:\", inventory[\"hat\"])\n", + "print(\"book:\", inventory[\"book\"])\n", + "print(\"keychain:\", inventory[\"keychain\"])\n", + "\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -68,7 +146,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.3" } }, "nbformat": 4,