From 34cad0a6b870d7bcf92ea11e835c2676977e0803 Mon Sep 17 00:00:00 2001 From: Kanak2208 Date: Thu, 15 Jan 2026 21:05:33 +0100 Subject: [PATCH 1/2] Week1Lab1 Done --- lab-python-data-structures.ipynb | 130 ++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..98d0c37f 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,137 @@ "\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": [], + "source": [ + "#1\n", + "products = (\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\")\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "#2 \n", + "inventory = { }" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 45, 'mug': 56, 'hat': 33, 'book': 41, 'keychain': 70}\n" + ] + } + ], + "source": [ + "#3 \n", + "q1 = int(input(\"Quantity of t-shirt: \"))\n", + "inventory['t-shirt'] = q1\n", + "\n", + "q2 = int(input(\"Quantity of mug: \"))\n", + "inventory['mug'] = q2\n", + "\n", + "q3 = int(input(\"Quantity of hat: \"))\n", + "inventory['hat'] = q3\n", + "\n", + "q4 = int(input(\"Quantity of book: \"))\n", + "inventory['book'] = q4\n", + "\n", + "q5 = int(input(\"Quantity of keychain: \"))\n", + "inventory['keychain'] = q5\n", + "\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "#4.\n", + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt', 'hat', 'kechain'}\n" + ] + } + ], + "source": [ + "#5. \n", + "o1 = input(\"Enter Product 1 to Order: \")\n", + "customer_orders.add(o1)\n", + "\n", + "o2 = input(\"Enter Product 2to Order: \")\n", + "customer_orders.add(o2)\n", + "\n", + "o3 = input(\"Enter Product 3 to Order: \")\n", + "customer_orders.add(o3)\n", + "\n", + "#6\n", + "print(customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "3\n" + ] + } + ], + "source": [ + "#7. total number of products in the customer order set\n", + "print(len(customer_orders))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -68,7 +194,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.2" } }, "nbformat": 4, From 78509d0eb855b4d1cca3f68d328201c116c7274a Mon Sep 17 00:00:00 2001 From: Kanak2208 Date: Sat, 17 Jan 2026 13:24:48 +0100 Subject: [PATCH 2/2] Lab1 Done --- lab-python-data-structures.ipynb | 74 +++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 98d0c37f..1ccb025f 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -76,7 +76,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [ { @@ -104,7 +104,10 @@ "q5 = int(input(\"Quantity of keychain: \"))\n", "inventory['keychain'] = q5\n", "\n", - "print(inventory)" + "print(inventory)\n", + "\n", + "#for i range(5)\n", + " #" ] }, { @@ -147,20 +150,54 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "3\n" + "3\n", + "60.0 %\n" ] } ], "source": [ "#7. total number of products in the customer order set\n", - "print(len(customer_orders))" + "print(len(customer_orders))\n", + "\n", + "#Percentage of Products Ordered from the inventory\n", + "percentage_po = len(customer_orders)*100/len(inventory)\n", + "print(percentage_po, '%')\n", + "\n", + "#Store these statistics in a tuple called `order_status`\n", + "\n", + "order_status = (len(customer_orders), percentage_po)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0 %\n" + ] + } + ], + "source": [ + "#8. Print order status\n", + "\n", + "#print(order_status)\n", + "print('Order Statistics:')\n", + "print('Total Products Ordered:', len(customer_orders))\n", + "print('Percentage of Products Ordered:', (percentage_po),'%')" ] }, { @@ -168,7 +205,13 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [] + "source": [ + "#9.\n", + "\n", + "for product in inventory:\n", + " inventory[product] = inventory[product] - 1\n", + "\n" + ] }, { "cell_type": "markdown", @@ -176,6 +219,25 @@ "source": [ "\n" ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 43, 'mug': 55, 'hat': 31, 'book': 40, 'keychain': 69}\n" + ] + } + ], + "source": [ + "#10. \n", + "\n", + "print(inventory)" + ] } ], "metadata": {