From f5334c10195c8600d7f69a676007290a1afa7aec Mon Sep 17 00:00:00 2001 From: Enia Lahcene Date: Sun, 22 Sep 2024 21:45:31 +0100 Subject: [PATCH 1/3] Solved lab --- .DS_Store | Bin 0 -> 6148 bytes lab-python-data-structures.ipynb | 175 ++++++++++++++++++++++++++++++- 2 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..14c56436f08a5f4681e81ac744ff24740119ee7b GIT binary patch literal 6148 zcmeHKJ5Iwu5S<||EYYN-+!G*0TwoJSA1N0=AyPm}D0^lY*E(lFLgAQT7%P728PA;AT+V=>fE2NoRxfbtu!hHITAfJp+t>{tvDfw576 zMr9u{*yxBSugi|b(CEZ^GVbFivrj0jrz4)UoH!fC8VZC0eFa9g9ZUbegP)oI`=r=~ z0-?a4Qh=*w(ai8l-dhJRC%rbo@8REuS}n(-tr)1S7#nHDSDm^f*T`qbVyJY)l@5#_ N0nsHa6!;AVz5sLRDEa^Z literal 0 HcmV?d00001 diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..b9542fbe 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +50,179 @@ "\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": 61, + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [], + "source": [ + "inventory[products[0]] = int(input(f\"Give me the quantity of {products[0]}: \"))\n", + "inventory[products[1]] = int(input(f\"Give me the quantity of {products[1]}: \"))\n", + "inventory[products[2]] = int(input(f\"Give me the quantity of {products[2]}: \"))\n", + "inventory[products[3]] = int(input(f\"Give me the quantity of {products[3]}: \"))\n", + "inventory[products[4]] = int(input(f\"Give me the quantity of {products[4]}: \"))" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 2, 'mug': 3, 'hat': 4, 'book': 1, 'keychain': 5}\n" + ] + } + ], + "source": [ + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'mug', 'hat', 'book'}\n" + ] + } + ], + "source": [ + "product1 = input(f\"Give me the name of a product you want to oredered it. Choose one of this list {products}\")\n", + "product2 = input(f\"Give me the name of a product you want to oredered it. Choose one of this list {products}\")\n", + "product3 = input(f\"Give me the name of a product you want to oredered it. Choose one of this list {products}\")\n", + "\n", + "customer_orders.add(product1)\n", + "customer_orders.add(product2)\n", + "customer_orders.add(product3)\n", + "\n", + "print(customer_orders)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [], + "source": [ + "num_products = len(customer_orders)\n", + "percentage = num_products/len(products)*100\n", + "\n", + "order_status = (num_products,percentage)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + " Order Statistics:\n", + " Total Products Ordered: 3\n", + " Percentage of Products Ordered: 60.0 \n", + " \n" + ] + } + ], + "source": [ + "print(f'''\n", + " Order Statistics:\n", + " Total Products Ordered: {num_products}\n", + " Percentage of Products Ordered: {percentage} \n", + " ''')" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [], + "source": [ + "inventory[product1]-= 1\n", + "inventory[product2]-= 1\n", + "inventory[product3]-= 1\n" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Updated inventory: \n", + "\n", + " t-shirt: 2 \n", + "\n", + " mug: 2 \n", + "\n", + " hat: 3 \n", + "\n", + " book: 0 \n", + "\n", + " keychain: 5 \n", + "\n", + " \n" + ] + } + ], + "source": [ + "print(f''' Updated inventory: \\n\n", + " {products[0]}: {inventory[products[0]]} \\n\n", + " {products[1]}: {inventory[products[1]]} \\n\n", + " {products[2]}: {inventory[products[2]]} \\n\n", + " {products[3]}: {inventory[products[3]]} \\n\n", + " {products[4]}: {inventory[products[4]]} \\n\n", + " ''' )\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -68,7 +241,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.12.6" } }, "nbformat": 4, From 05764e488f671fca0530005e9083f5048da0cf51 Mon Sep 17 00:00:00 2001 From: Enia Lahcene Date: Sun, 22 Sep 2024 22:06:34 +0100 Subject: [PATCH 2/3] Solved lab --- .DS_Store | Bin 6148 -> 6148 bytes lab-python-data-structures.ipynb | 7 +++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.DS_Store b/.DS_Store index 14c56436f08a5f4681e81ac744ff24740119ee7b..4234cc4e039645e314ff177d54c32726470feffe 100644 GIT binary patch delta 113 zcmZoMXfc?uEOzNh1_lNe20ey!hD?T%+ Date: Sun, 22 Sep 2024 22:11:45 +0100 Subject: [PATCH 3/3] Solved lab --- .DS_Store | Bin 6148 -> 6148 bytes lab-python-data-structures.ipynb | 6 ++++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.DS_Store b/.DS_Store index 4234cc4e039645e314ff177d54c32726470feffe..984a9238b3929c4eaa29b39f42a82ead997f0216 100644 GIT binary patch delta 113 zcmZoMXfc?uEOuio0|NsKgC0XVLncE>ZoZ34QcivnP>kcUv$t-1z%fTu`4qhJ1sR6H c$@#ejKs^i$Oba#(GJa#5SirZLo#QV*0FFN$bpQYW delta 113 zcmZoMXfc?uEOzNh1_lNe20ey!hD?T%+ 0:\n", + " inventory[product] -= 1\n", + "\n" ] }, {