diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..bdf4a965 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,13 +50,98 @@ "\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": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter the ammount for each t-shirt 2\n", + "Enter the ammount for each mug 3\n", + "Enter the ammount for each hat 2\n", + "Enter the ammount for each book 3\n", + "Enter the ammount for each keychain 4\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "What are the 3 products do you want to order?\n" + ] + }, + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Insert the product 1 book\n", + "Insert the product 2 hat\n", + "Insert the product 3 mug\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Products ordered are {'book', 'mug', 'hat'}\n", + "Total products ordered are: 8\n", + "Percentage of products ordered is: 37.5 %)\n", + "2\n", + "2\n", + "1\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\",\"mug\",\"hat\",\"book\",\"keychain\"] \n", + "inventory = {}\n", + "for key in products:\n", + " number = int(input(f\"Enter the ammount for each {key}\"))\n", + " inventory[key] = number\n", + "customers_orders = set()\n", + "print(\"What are the 3 products do you want to order?\")\n", + "for x in range(3):\n", + " order = input(f\"Insert the product {x + 1}\")\n", + " customers_orders.add(order)\n", + "print(\"Products ordered are\", customers_orders)\n", + "total_number = 0\n", + "for key in customers_orders:\n", + " total_number += inventory[key]\n", + "percentage = (len(customers_orders) / total_number) * 100\n", + "print(\"Total products ordered are:\", total_number)\n", + "print(\"Percentage of products ordered is:\", percentage, \"%)\")\n", + "\n", + "for key in customers_orders:\n", + " if key in inventory:\n", + " inventory[key] - 1\n", + " subtract = inventory[key]\n", + " print(subtract - 1)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python [conda env:base] *", "language": "python", - "name": "python3" + "name": "conda-base-py" }, "language_info": { "codemirror_mode": { @@ -68,7 +153,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" } }, "nbformat": 4,