diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..385c1594 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +50,83 @@ "\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": [ + "#1 List \n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "\n", + "#2 Dictionary\n", + "inventory = {}\n", + "\n", + "#3 \n", + "inventory[\"t-shirt\"] = int(input(\"Enter t-shirt quantity: \"))\n", + "inventory[\"mug\"] = int(input(\"Enter mug quantity: \"))\n", + "inventory[\"hat\"] = int(input(\"Enter hat quantity: \"))\n", + "inventory[\"book\"] = int(input(\"Enter book quantity: \"))\n", + "inventory[\"keychain\"] = int(input(\"Enter keychain quantity: \"))\n", + "\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#4\n", + "customer_orders = set()\n", + "\n", + "#5\n", + "product_name = input(\"Enter the name of the product that you order: \")\n", + "customer_orders.add(product_name)\n", + "\n", + "product_name = input(\"Enter the name of the product that you order: \")\n", + "customer_orders.add(product_name)\n", + "\n", + "product_name = input(\"Enter the name of the product that you order: \")\n", + "customer_orders.add(product_name)\n", + "\n", + "#6\n", + "print(\"Products in customer order: \", customer_orders) " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "#7\n", + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = (total_products_ordered/len(products)) * 100\n", + "\n", + "order_stats = (total_products_ordered, percentage_ordered)\n", + "\n", + "#8\n", + "print(\"Order Statistics: \")\n", + "print(f\"Total Products Ordered: {len(customer_orders)}\")\n", + "print(f\"Percentage of Products Ordered: {percentage_ordered}%\")\n", + "\n", + "\n", + "#9\n", + "list(product_name)[0]\n", + "inventory[product_name] -= 1\n", + "\n", + "list(product_name)[1]\n", + "inventory[product_name] -= 1\n", + "\n", + "list(product_name)[2]\n", + "inventory[product_name] -= 1\n", + "\n", + "print(inventory)" + ] } ], "metadata": {