From 80e2887b1f0538713a966c7e29e3de4270af7777 Mon Sep 17 00:00:00 2001 From: Helena Krenzlin Date: Thu, 15 Jan 2026 21:08:08 +0100 Subject: [PATCH 1/2] WeekLab1Done --- lab-python-data-structures.ipynb | 124 ++++++++++++++++++++++++++++++- 1 file changed, 122 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..2b9ba304 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,131 @@ "\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": 54, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['t-shirt', 'mug', 'hat', 'book', 'keychain']\n" + ] + } + ], + "source": [ + "#1 \n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "print (products)" + ] + }, + { + "cell_type": "code", + "execution_count": 55, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{}\n" + ] + } + ], + "source": [ + "#2 \n", + "inventory ={}\n", + "print (inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 56, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 600, 'mug': 200, 'hat': 50, 'book': 200, 'keychain': 104}\n" + ] + } + ], + "source": [ + "#3\n", + "for item in products: \n", + " value = int(input(f\"Enter the quantity for {item}: \"))\n", + " inventory[item] = value\n", + "print (inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "set()\n" + ] + } + ], + "source": [ + "#4\n", + "customer_orders = set()\n", + "print (customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt', 'mug', 'book'}\n" + ] + } + ], + "source": [ + "#5\n", + "product_1 = input(\"Enter a product name:\")\n", + "product_2 = input(\"Enter a product name:\")\n", + "product_3 = input(\"Enter a product name:\")\n", + "customer_orders.add(product_1)\n", + "customer_orders.add(product_2)\n", + "customer_orders.add(product_3)\n", + "print (customer_orders)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt', 'mug', 'book'}\n" + ] + } + ], + "source": [ + "#6\n", + "print (customer_orders)" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +188,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.9" } }, "nbformat": 4, From b118529a57e2854dc6109e956483f9ddcdec4acb Mon Sep 17 00:00:00 2001 From: Helena Krenzlin Date: Fri, 16 Jan 2026 21:09:27 +0100 Subject: [PATCH 2/2] WeekLab12.0-Done --- lab-python-data-structures.ipynb | 105 ++++++++++++++++++++++++++++--- 1 file changed, 96 insertions(+), 9 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 2b9ba304..742aead0 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -72,7 +72,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -91,14 +91,14 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 34, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{'t-shirt': 600, 'mug': 200, 'hat': 50, 'book': 200, 'keychain': 104}\n" + "{'t-shirt': 500, 'mug': 400, 'hat': 300, 'book': 40, 'keychain': 50}\n" ] } ], @@ -112,7 +112,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 35, "metadata": {}, "outputs": [ { @@ -131,14 +131,14 @@ }, { "cell_type": "code", - "execution_count": 72, + "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{'t-shirt', 'mug', 'book'}\n" + "{'mug', 't-shirt', 'book'}\n" ] } ], @@ -155,14 +155,14 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "{'t-shirt', 'mug', 'book'}\n" + "{'mug', 't-shirt', 'book'}\n" ] } ], @@ -170,6 +170,93 @@ "#6\n", "print (customer_orders)" ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(1290, 0.23255813953488372)\n" + ] + } + ], + "source": [ + "#7\n", + "total_numbers_orders = len(customer_orders)\n", + "total_inventory_values = sum(inventory.values())\n", + "percentage_of_products_ordered = (total_numbers_orders/total_inventory_values)*100\n", + "order_status= (total_inventory_values , percentage_of_products_ordered)\n", + "print (order_status)" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 0.23255813953488372 %\n" + ] + } + ], + "source": [ + "#8 Order statistics\n", + "print (\"Total Products Ordered:\",total_numbers_orders)\n", + "print (\"Percentage of Products Ordered:\",percentage_of_products_ordered,\"%\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 499, 'mug': 399, 'hat': 299, 'book': 39, 'keychain': 49}\n" + ] + } + ], + "source": [ + "#9\n", + "for product in inventory: \n", + " inventory[product] = inventory[product] -1\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Updated Inventory Status:\n", + "t-shirt: 499\n", + "mug: 399\n", + "hat: 299\n", + "book: 39\n", + "keychain: 49\n" + ] + } + ], + "source": [ + "#10\n", + "print (\"Updated Inventory Status:\")\n", + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\")" + ] } ], "metadata": {