diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..e1d225ac 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +50,68 @@ "\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": [ + "# ANSWER HERE" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#Program that manages customer orders and inventory by Cecilia Betek\n", + "# 1. Define a list called products\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "# 2. Create an empty dictionary\n", + "inventory = {}\n", + "# 3.\n", + "inventory = {\"t-shirt\":20, \"mug\": 5, \"hat\":15, \"book\": 24, \"keychain\": 19}\n", + "#4\n", + "for product in products:\n", + " quantity = int(input(f\"Enter quantity for {product}: \"))\n", + " inventory[product] = quantity\n", + "#4\n", + "customer_orders = set()\n", + "#5\n", + "print(\"\\nAvailable products:\", products)\n", + "for i in range(3):\n", + " order = input(f\"Enter product #{i+1} to order: \").lower()\n", + " if order in products:\n", + " customer_orders.add(order)\n", + " else:\n", + " print(\"Invalid product, please choose from the list.\")\n", + "#6\n", + "print(\"\\nCustomer Orders:\", customer_orders)\n", + "#7\n", + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = (total_products_ordered / len(products)) * 100\n", + "#8\n", + "order_status = (total_products_ordered, percentage_ordered)\n", + "#9\n", + "print(\"\\nOrder Statistics:\")\n", + "print(\"Total Products Ordered:\", order_status[0])\n", + "print(\"Percentage of Products Ordered: {:.2f}%\".format(order_status[1]))\n", + "# Step 10\n", + "for product in customer_orders:\n", + " if inventory[product] > 0:\n", + " inventory[product] -= 1\n", + "\n", + "# Step 11\n", + "print(\"\\nUpdated Inventory:\")\n", + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\")" + ] } ], "metadata": {