diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..e48e363e 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": [ + "Customer Orders: {'23', '67', '87'}\n", + "Inventory:\n", + "{'t-shirt': 12, 'mug': 23, 'hat': 45, 'book': 56, 'keychain': 65}\n" + ] + } + ], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "inventory = {}\n", + "\n", + "#Ask the user to input the quantity of each product available in the inventory. Use the product names from the `products` list as keys in the `inventory` dictionary and assign the respective quantities as values.\n", + "quantity1 = int(input(\"Enter the quantity for t-shirt: \"))\n", + "inventory[\"t-shirt\"] = quantity1\n", + "\n", + "quantity2 = int(input(\"Enter the quantity for mug: \"))\n", + "inventory[\"mug\"] = quantity2\n", + "\n", + "quantity3 = int(input(\"Enter the quantity for hat: \"))\n", + "inventory[\"hat\"] = quantity3 \n", + "\n", + "quantity4 = int(input(\"Enter the quantity for book: \"))\n", + "inventory[\"book\"] = quantity4\n", + "\n", + "quantity5 = int(input(\"Enter the quantity for keychain: \"))\n", + "inventory[\"keychain\"] = quantity5\n", + "\n", + "inventory\n", + "\n", + "customer_order = set()\n", + "\n", + "product1 = input(\"Enter the product you want to order: \")\n", + "customer_order.add(product1)\n", + "\n", + "product2 = input(\"Enter the product you want to order: \")\n", + "customer_order.add(product2)\n", + "\n", + "product3 = input(\"Enter the product you want to order: \")\n", + "customer_order.add(product3)\n", + "\n", + "print(\"Customer order:\", customer_order)\n", + "\n", + "total_products_ordered = len(customer_order)\n", + "percentage_of_products_ordered = total_products_ordered/ len(products) * 100\n", + "\n", + "order_status = tuple()\n", + "order_status = (total_products_ordered, percentage_of_products_ordered)\n", + "\n", + "print(\"Total Products Ordered:\", total_products_ordered)\n", + "\n", + "print(f\"Percentage of Products Ordered: {percentage_of_products_ordered}%\")\n", + "\n", + "\n", + "#Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", + "\n", + "inventory[product1] = inventory[product1] - 1\n", + "inventory[product2] = inventory[product2] - 1\n", + "inventory[product3] = inventory[product3] - 1\n", + "\n", + "\n", + "#Print the updated inventory, displaying the quantity of each product on separate lines.\n", + "\n", + "print(\"Updated quantity for t-shirt:\", inventory[\"t-shirt\"])\n", + "print(\"Updated quantity for mug:\", inventory[\"mug\"])\n", + "print(\"Updated quantity for hat:\", inventory[\"hat\"])\n", + "print(\"Updated quantity for book:\", inventory[\"book\"])\n", + "print(\"Updated quantity for keychain:\", inventory[\"keychain\"])\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +146,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4,