From b9c00397ec52a1af2b804dba58ce3d6a58452271 Mon Sep 17 00:00:00 2001 From: Hossein Vesali Date: Fri, 6 Mar 2026 18:06:48 +0100 Subject: [PATCH 1/2] Solved lab --- lab-python-data-structures.ipynb | 151 ++++++++++++++++++++++++++++++- 1 file changed, 150 insertions(+), 1 deletion(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..f04a58bd 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,6 +50,155 @@ "\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": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + " Enter the inventory quantity of t-shirt: 4\n", + " Enter the inventory quantity of mug: 3\n", + " Enter the inventory quantity of hat: 4\n", + " Enter the inventory quantity of book: 3\n", + " Enter the inventory quantity of keychain: 4\n", + "Enter 3 products to order: ss\n" + ] + }, + { + "data": { + "text/plain": [ + "'ss'" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "products=[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"] #1\n", + "\n", + "inventory={} #2\n", + "\n", + "for x in products: #3\n", + " qnt =input (f\" Enter the inventory quantity of {x}: \")\n", + " inventory[x] = int(qnt)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "name": "stdin", + "output_type": "stream", + "text": [ + "Enter a product (t-shirt, mug, hat, book, keychain): hat\n", + "Enter a product (t-shirt, mug, hat, book, keychain): mug\n", + "Enter a product (t-shirt, mug, hat, book, keychain): book\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'mug', 'book', 'hat'}\n" + ] + } + ], + "source": [ + "customer_orders = set() #4\n", + "\n", + "for i in range(3): #5\n", + " product = input(\"Enter a product (t-shirt, mug, hat, book, keychain): \")\n", + " if product in products:\n", + " customer_orders.add(product)\n", + " else:\n", + " print(\"Invalid product. Please enter one of the listed products.\")\n", + " \n", + "print (customer_orders) #6\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(3, 60.0)\n" + ] + } + ], + "source": [ + "\n", + "total_products_ordered = len(customer_orders) #7\n", + "\n", + "percentage_products_ordered = (total_products_ordered / len(products)) * 100 \n", + "\n", + "order_status = (total_products_ordered, percentage_products_ordered)\n", + "\n", + "print(order_status)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0%\n" + ] + } + ], + "source": [ + "print(\"Order Statistics:\") #8\n", + "print(f\"Total Products Ordered: {total_products_ordered}\")\n", + "print(f\"Percentage of Products Ordered: {percentage_products_ordered}%\")" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "t-shirt 3\n", + "mug 2\n", + "hat 3\n", + "book 2\n", + "keychain 3\n" + ] + } + ], + "source": [ + "for product in inventory: #9\n", + " inventory[product] -= 1\n", + " print(product, inventory[product])#10" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -68,7 +217,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.9.6" } }, "nbformat": 4, From 022dffaa0e233736eec1a38e00be7dcfbff8aed1 Mon Sep 17 00:00:00 2001 From: baharmnb Date: Fri, 6 Mar 2026 18:20:36 +0100 Subject: [PATCH 2/2] Updated README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b66b7a56..c2e5ccbe 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Before this starting this lab, you should have learnt about: ## Introduction -Welcome to your first data analytics bootcamp lab! In this lab, you will have the opportunity to dive into one of the fundamental building blocks of Python programming: data structures. +Welcome to your first data analytics bootcamp lab!!! In this lab, you will have the opportunity to dive into one of the fundamental building blocks of Python programming: data structures. As you may already know, data structures are collections of values that can be used to organize and manipulate data more efficiently, such as lists, dictionaries, sets, and tuples.