From ca8b5f93ae007f3ea65a8129501af165e0544a9f Mon Sep 17 00:00:00 2001 From: prodduturisindhurdy Date: Tue, 7 Oct 2025 14:25:25 +0100 Subject: [PATCH 1/4] Lab Done --- lab-python-data-structures.ipynb | 176 ++++++++++++++++++++++++++++++- 1 file changed, 174 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..366eb3e8 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,183 @@ "\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": 1, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['t-shirts', 'mug', 'hat', 'book', 'keychain']" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "products=[\"t-shirts\",\"mug\",\"hat\",\"book\",\"keychain\"]\n", + "products" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "inventory={}" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "inventory[\"t-shirts\"]=int(input(\"enter the quantity of t-shirts\"))\n", + "inventory[\"mug\"]=int(input(\"enter the quantity of mug\"))\n", + "inventory[\"hat\"]=int(input(\"enter the quantity of hat\"))\n", + "inventory[\"book\"]=int(input(\"enter the quantity of book\"))\n", + "inventory[\"keychain\"]=int(input(\"enter the quantity of keychain\"))" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "customers_orders=set()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'book', 'hat', 'mug'}" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "order1=input(\"enter your order\")\n", + "order2=input(\"enter your order\")\n", + "order3=input(\"enter your order\")\n", + "if order1 in products:\n", + " customers_orders.add(order1)\n", + "else:\n", + " print(\"order1 not found\")\n", + "if order2 in products:\n", + " customers_orders.add(order2)\n", + "else:\n", + " print(\"order2 not found\")\n", + "if order3 in products:\n", + " customers_orders.add(order3)\n", + "else:\n", + " print(\"order3 not found\")\n", + "customers_orders" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n", + "3\n" + ] + } + ], + "source": [ + "total_products_order=len(customers_orders)\n", + "print(total_products_order)\n", + "percentage_of_product_order=total_products_order % len(products)\n", + "print(percentage_of_product_order)" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirts': 9, 'mug': 19, 'hat': 29, 'book': 39, 'keychain': 49}" + ] + }, + "execution_count": 7, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory[\"t-shirts\"] -=1\n", + "inventory[\"mug\"] -=1\n", + "inventory[\"hat\"] -=1\n", + "inventory[\"book\"] -=1\n", + "inventory[\"keychain\"] -=1\n", + "inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "t-shirts: 9\n", + "mug: 19\n", + "hat: 29\n", + "book: 39\n", + "keychain: 49\n" + ] + } + ], + "source": [ + "print(\"t-shirts:\",inventory[\"t-shirts\"] )\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": [] + }, + { + "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 +240,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.11.9" } }, "nbformat": 4, From 3cf4bf436cf2ea431ec8463d9d57eb9a2e9c60ba Mon Sep 17 00:00:00 2001 From: prodduturisindhurdy Date: Tue, 7 Oct 2025 15:05:16 +0100 Subject: [PATCH 2/4] Lab Done --- lab-python-data-structures.ipynb | 83 +++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 29 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 366eb3e8..2966e766 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -68,7 +68,7 @@ } ], "source": [ - "products=[\"t-shirts\",\"mug\",\"hat\",\"book\",\"keychain\"]\n", + "products=[\"t-shirt\",\"mug\",\"hat\",\"book\",\"keychain\"]\n", "products" ] }, @@ -83,11 +83,11 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "inventory[\"t-shirts\"]=int(input(\"enter the quantity of t-shirts\"))\n", + "inventory[\"t-shirt\"]=int(input(\"enter the quantity of t-shirt\"))\n", "inventory[\"mug\"]=int(input(\"enter the quantity of mug\"))\n", "inventory[\"hat\"]=int(input(\"enter the quantity of hat\"))\n", "inventory[\"book\"]=int(input(\"enter the quantity of book\"))\n", @@ -96,51 +96,56 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 12, "metadata": {}, "outputs": [], "source": [ - "customers_orders=set()" + "customer_orders=set()" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 16, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'book', 'hat', 'mug'}" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "order1=input(\"enter your order\")\n", "order2=input(\"enter your order\")\n", "order3=input(\"enter your order\")\n", "if order1 in products:\n", - " customers_orders.add(order1)\n", + " customer_orders.add(order1)\n", "else:\n", " print(\"order1 not found\")\n", "if order2 in products:\n", - " customers_orders.add(order2)\n", + " customer_orders.add(order2)\n", "else:\n", " print(\"order2 not found\")\n", "if order3 in products:\n", - " customers_orders.add(order3)\n", + " customer_orders.add(order3)\n", "else:\n", - " print(\"order3 not found\")\n", - "customers_orders" + " print(\"order3 not found\")\n" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'hat', 'mug', 'book'}\n" + ] + } + ], + "source": [ + "print(customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -148,15 +153,35 @@ "output_type": "stream", "text": [ "3\n", - "3\n" + "60.0\n", + "(3, 60.0)\n" ] } ], "source": [ - "total_products_order=len(customers_orders)\n", + "total_products_order=len(customer_orders)\n", "print(total_products_order)\n", - "percentage_of_product_order=total_products_order % len(products)\n", - "print(percentage_of_product_order)" + "percentage_ordered=(total_products_order / len(products)) * 100\n", + "print(percentage_ordered)\n", + "order_status=(total_products_order,percentage_ordered)\n", + "print(order_status)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "total products order is 3 , percentage of products ordered is 60.0\n" + ] + } + ], + "source": [ + "print(f\"total products order is {total_products_order} , percentage of products ordered is {percentage_ordered}\")" ] }, { From ed5687b7b67285ed1ea0f850b3d1ea46de0b53d0 Mon Sep 17 00:00:00 2001 From: prodduturisindhurdy Date: Tue, 7 Oct 2025 15:14:25 +0100 Subject: [PATCH 3/4] Lab Done --- lab-python-data-structures.ipynb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 2966e766..4af898e6 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -169,19 +169,23 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "total products order is 3 , percentage of products ordered is 60.0\n" + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0\n" ] } ], "source": [ - "print(f\"total products order is {total_products_order} , percentage of products ordered is {percentage_ordered}\")" + "print(\"Order Statistics:\")\n", + "print(\"Total Products Ordered:\", order_status[0])\n", + "print(\"Percentage of Products Ordered:\", order_status[1])" ] }, { From 750f89520358bab66618b85727c3e1a6e43f83ae Mon Sep 17 00:00:00 2001 From: prodduturisindhurdy Date: Tue, 7 Oct 2025 15:17:57 +0100 Subject: [PATCH 4/4] Solved Done --- lab-python-data-structures.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 4af898e6..07b6a4ae 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -190,7 +190,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -205,7 +205,7 @@ } ], "source": [ - "inventory[\"t-shirts\"] -=1\n", + "inventory[\"t-shirt\"] -=1\n", "inventory[\"mug\"] -=1\n", "inventory[\"hat\"] -=1\n", "inventory[\"book\"] -=1\n", @@ -215,7 +215,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -231,7 +231,7 @@ } ], "source": [ - "print(\"t-shirts:\",inventory[\"t-shirts\"] )\n", + "print(\"t-shirt:\",inventory[\"t-shirt\"] )\n", "print(\"mug:\",inventory[\"mug\"] )\n", "print(\"hat:\",inventory[\"hat\"] )\n", "print(\"book:\",inventory[\"book\"] )\n",