From a027c95fa7fd1ef3a17b1eadcaf1e1f5427321a6 Mon Sep 17 00:00:00 2001 From: Goldie V Date: Fri, 16 Jan 2026 16:22:34 +0100 Subject: [PATCH 1/2] lab done --- lab-python-data-structures.ipynb | 94 +++++++++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..6405c154 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,101 @@ "\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": 19, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Products in customer order: {'book', 'mug', 'hat'}\n", + "Order Statistics\n", + "Total Products ordered: 3\n", + "Percentage of Products ordered: 60.0 %\n", + "Updated_Inventory: \n", + "T-shirt 5\n", + "Mug 1\n", + "Hat 5\n", + "Book 3\n", + "Keychain 2\n" + ] + } + ], + "source": [ + "#1\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "\n", + "#2 \n", + "inventory = {}\n", + "#3\n", + "quantity = int(input(\"Please enter the quantity of t-shirt in inventory: \"))\n", + "inventory[\"t-shirt\"] = quantity\n", + "\n", + "quantity = int(input(\"Please enter the quantity of mug in inventory: \"))\n", + "inventory[\"mug\"] = quantity\n", + "\n", + "quantity = int(input(\"Please enter the quantity of hat in inventory: \"))\n", + "inventory[\"hat\"] = quantity\n", + "\n", + "quantity = int(input(\"Please enter the quantity of book in inventory: \"))\n", + "inventory[\"book\"] = quantity\n", + "\n", + "quantity = int(input(\"Please enter the quantity of keychain in inventory: \"))\n", + "inventory[\"keychain\"] = quantity\n", + "\n", + "#4\n", + "customer_orders = set()\n", + "\n", + "#5\n", + "product_name = input(\"Please enter the product name the customer wants to order: \").lower()\n", + "customer_orders.add(product_name)\n", + "\n", + "product_name = input(\"Please enter the product name the customer wants to order: \").lower()\n", + "customer_orders.add(product_name)\n", + "\n", + "product_name = input(\"Please enter the product name the customer wants to order: \").lower()\n", + "customer_orders.add(product_name)\n", + "\n", + "#6\n", + "print(\"Products in customer order: \", customer_orders)\n", + "\n", + "#7\n", + "total_products_ordered = len(customer_orders)\n", + "percentage_ordered = total_products_ordered/len(products) * 100 \n", + "order_status = (total_products_ordered, percentage_ordered)\n", + "\n", + "#8\n", + "print(\"Order Statistics\")\n", + "print(\"Total Products ordered: \", order_status[0])\n", + "print(\"Percentage of Products ordered: \", order_status[1],\"%\")\n", + "\n", + "#9\n", + "product_name = customer_orders.pop()\n", + "inventory[product_name] -= 1\n", + "\n", + "#10\n", + "print(\"Updated_Inventory: \")\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\"])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -68,7 +158,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.2" } }, "nbformat": 4, From d06bc04e640a2c19fa623625e32e2e199e1c170e Mon Sep 17 00:00:00 2001 From: Goldie V Date: Fri, 16 Jan 2026 17:13:59 +0100 Subject: [PATCH 2/2] lab done --- lab-python-data-structures.ipynb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 6405c154..b4a6cceb 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -133,13 +133,6 @@ "print(\"Book\", inventory[\"book\"])\n", "print(\"Keychain\", inventory[\"keychain\"])" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {