From 33123d465536afe2cda243560d95c766360c5248 Mon Sep 17 00:00:00 2001 From: Sana Aarsman Date: Wed, 19 Nov 2025 11:42:27 +0100 Subject: [PATCH 1/6] Mofified exersize 1 till 9 --- lab-python-data-structures.ipynb | 153 ++++++++++++++++++++++++++++++- 1 file changed, 151 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..21972264 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,160 @@ "\n", "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1, 2, 3:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "\n", + "for product in products:\n", + " quantity = input(f\"Enter the quantity of '{product}' in stock:\")\n", + " inventory[product] = int(quantity)\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4, 5, 6:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Your order contains: {'book', 'mug', 'hat'}\n" + ] + } + ], + "source": [ + "customer_order = set()\n", + "\n", + "while len(customer_order) < 3:\n", + " item = input(\"Enter the name of a product to order(t-shirt, mug, hat, book, keychain): \").strip()\n", + " if item in products:\n", + " customer_order.add(item)\n", + " else:\n", + " print(\"Sorry, we don't have that product. Please choose from the available products.(t-shirt, mug, hat, book, keychain)\")\n", + "print(f\"Your order contains: {customer_order}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "7:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Order stattistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0%\n" + ] + } + ], + "source": [ + "total_products_ordered = len(customer_order)\n", + "total_inventory = len(inventory)\n", + "percentage_order = (total_products_ordered / total_inventory) * 100\n", + "order_status = (total_products_ordered, percentage_order)\n", + "print(f\"Order stattistics:\\nTotal Products Ordered: {total_products_ordered}\\nPercentage of Products Ordered: {percentage_order}%\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "9:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "'book' has been shipped. Remaining stock: 1\n", + "'mug' has been shipped. Remaining stock: 1\n", + "'hat' has been shipped. Remaining stock: 1\n" + ] + } + ], + "source": [ + "for product in customer_order:\n", + " if inventory[product] > 0:\n", + " inventory[product] -= 1\n", + " print(f\"'{product}' has been shipped. Remaining stock: {inventory[product]}\")\n", + " else:\n", + " print(f\"Sorry, '{product}' is out of stock and cannot be shipped.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "10:\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 2, 'mug': 1, 'hat': 1, 'book': 1, 'keychain': 2}" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "print(inventory)\\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -68,7 +217,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.11.4" } }, "nbformat": 4, From dccf9cd51e3c0d4cae4d7a03cc3997cffd5ca8db Mon Sep 17 00:00:00 2001 From: Sana Aarsman Date: Wed, 19 Nov 2025 12:38:11 +0100 Subject: [PATCH 2/6] Modified exersize 10 --- lab-python-data-structures.ipynb | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 21972264..72f7dabd 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -175,22 +175,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 7, "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "{'t-shirt': 2, 'mug': 1, 'hat': 1, 'book': 1, 'keychain': 2}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "t-shirt: 2\n", + "mug: 1\n", + "hat: 1\n", + "book: 1\n", + "keychain: 2\n" + ] } ], "source": [ - "print(inventory)\\n" + "for product in products:\n", + " print(f\"{product}: {inventory[product]}\")" ] }, { From 62b9330ad1e37b0ea1a9c399a108c1d3873e8bd1 Mon Sep 17 00:00:00 2001 From: Sana Aarsman Date: Wed, 19 Nov 2025 12:56:22 +0100 Subject: [PATCH 3/6] Modified the structure --- lab-python-data-structures.ipynb | 131 +++++++++++++++++++++++-------- 1 file changed, 98 insertions(+), 33 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 72f7dabd..5e16632e 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -55,7 +55,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "1, 2, 3:" + "1:" ] }, { @@ -64,44 +64,101 @@ "metadata": {}, "outputs": [], "source": [ - "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", - "inventory = {}\n", - "\n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "2:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ "for product in products:\n", " quantity = input(f\"Enter the quantity of '{product}' in stock:\")\n", - " inventory[product] = int(quantity)\n", - "\n" + " inventory[product] = int(quantity)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "4, 5, 6:" + "4:" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "customer_order = set()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "5:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "while len(customer_order) < 3:\n", + " item = input(\"Enter the name of a product to order(t-shirt, mug, hat, book, keychain): \").strip()\n", + " if item in products:\n", + " customer_order.add(item)\n", + " else:\n", + " print(\"Sorry, we don't have that product. Please choose from the available products.(t-shirt, mug, hat, book, keychain)\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "6:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Your order contains: {'book', 'mug', 'hat'}\n" + "Your order contains: {'mug', 'hat', 'book'}\n" ] } ], "source": [ - "customer_order = set()\n", - "\n", - "while len(customer_order) < 3:\n", - " item = input(\"Enter the name of a product to order(t-shirt, mug, hat, book, keychain): \").strip()\n", - " if item in products:\n", - " customer_order.add(item)\n", - " else:\n", - " print(\"Sorry, we don't have that product. Please choose from the available products.(t-shirt, mug, hat, book, keychain)\")\n", "print(f\"Your order contains: {customer_order}\")" ] }, @@ -114,7 +171,26 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "total_products_ordered = len(customer_order)\n", + "total_inventory = len(inventory)\n", + "percentage_order = (total_products_ordered / total_inventory) * 100\n", + "order_status = (total_products_ordered, percentage_order)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "8:" + ] + }, + { + "cell_type": "code", + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -128,10 +204,6 @@ } ], "source": [ - "total_products_ordered = len(customer_order)\n", - "total_inventory = len(inventory)\n", - "percentage_order = (total_products_ordered / total_inventory) * 100\n", - "order_status = (total_products_ordered, percentage_order)\n", "print(f\"Order stattistics:\\nTotal Products Ordered: {total_products_ordered}\\nPercentage of Products Ordered: {percentage_order}%\")" ] }, @@ -144,16 +216,16 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "'book' has been shipped. Remaining stock: 1\n", "'mug' has been shipped. Remaining stock: 1\n", - "'hat' has been shipped. Remaining stock: 1\n" + "'hat' has been shipped. Remaining stock: 1\n", + "'book' has been shipped. Remaining stock: 1\n" ] } ], @@ -175,7 +247,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -194,13 +266,6 @@ "for product in products:\n", " print(f\"{product}: {inventory[product]}\")" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { From 1ee3bcc0af6507488197bda76f109cc5b67830eb Mon Sep 17 00:00:00 2001 From: Sana Aarsman Date: Thu, 20 Nov 2025 10:39:06 +0100 Subject: [PATCH 4/6] Lab solved --- lab-python-data-structures.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5e16632e..3583d965 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -270,7 +270,7 @@ ], "metadata": { "kernelspec": { - "display_name": "base", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, From 78665a3dd02b2df3268199f09e59aea7e131abac Mon Sep 17 00:00:00 2001 From: Sana Aarsman Date: Thu, 20 Nov 2025 12:23:15 +0100 Subject: [PATCH 5/6] Corrected a typo --- lab-python-data-structures.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 3583d965..35e4eb96 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -204,7 +204,7 @@ } ], "source": [ - "print(f\"Order stattistics:\\nTotal Products Ordered: {total_products_ordered}\\nPercentage of Products Ordered: {percentage_order}%\")" + "print(f\"Order statistics:\\nTotal Products Ordered: {total_products_ordered}\\nPercentage of Products Ordered: {percentage_order}%\")" ] }, { From a3d8cff444358165d5975d1a563553b3a4173048 Mon Sep 17 00:00:00 2001 From: Sana Aarsman Date: Tue, 2 Dec 2025 14:25:52 +0100 Subject: [PATCH 6/6] Recommiting labs --- .DS_Store | Bin 0 -> 6148 bytes ...ab-python-data-structures-checkpoint.ipynb | 292 ++++++++++++++++++ lab-python-data-structures.ipynb | 2 +- 3 files changed, 293 insertions(+), 1 deletion(-) create mode 100644 .DS_Store create mode 100644 .ipynb_checkpoints/lab-python-data-structures-checkpoint.ipynb diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0\n", + " Percentage of Products Ordered: % \n", + " ```\n", + "\n", + "9. Update the inventory by subtracting 1 from the quantity of each product. Modify the `inventory` dictionary accordingly.\n", + "\n", + "10. Print the updated inventory, displaying the quantity of each product on separate lines.\n", + "\n", + "Solve the exercise by implementing the steps using the Python concepts of lists, dictionaries, sets, and basic input/output operations. " + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "1:" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "2:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "3:" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "for product in products:\n", + " quantity = input(f\"Enter the quantity of '{product}' in stock:\")\n", + " inventory[product] = int(quantity)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "4:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "customer_order = set()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "5:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "while len(customer_order) < 3:\n", + " item = input(\"Enter the name of a product to order(t-shirt, mug, hat, book, keychain): \").strip()\n", + " if item in products:\n", + " customer_order.add(item)\n", + " else:\n", + " print(\"Sorry, we don't have that product. Please choose from the available products.(t-shirt, mug, hat, book, keychain)\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "6:" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Your order contains: {'mug', 'hat', 'book'}\n" + ] + } + ], + "source": [ + "print(f\"Your order contains: {customer_order}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "7:" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [], + "source": [ + "total_products_ordered = len(customer_order)\n", + "total_inventory = len(inventory)\n", + "percentage_order = (total_products_ordered / total_inventory) * 100\n", + "order_status = (total_products_ordered, percentage_order)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "8:" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Order stattistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 60.0%\n" + ] + } + ], + "source": [ + "print(f\"Order statistics:\\nTotal Products Ordered: {total_products_ordered}\\nPercentage of Products Ordered: {percentage_order}%\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "9:" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "'mug' has been shipped. Remaining stock: 1\n", + "'hat' has been shipped. Remaining stock: 1\n", + "'book' has been shipped. Remaining stock: 1\n" + ] + } + ], + "source": [ + "for product in customer_order:\n", + " if inventory[product] > 0:\n", + " inventory[product] -= 1\n", + " print(f\"'{product}' has been shipped. Remaining stock: {inventory[product]}\")\n", + " else:\n", + " print(f\"Sorry, '{product}' is out of stock and cannot be shipped.\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "10:\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "t-shirt: 2\n", + "mug: 1\n", + "hat: 1\n", + "book: 1\n", + "keychain: 2\n" + ] + } + ], + "source": [ + "for product in products:\n", + " print(f\"{product}: {inventory[product]}\")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.11.4" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 35e4eb96..63653e5e 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -270,7 +270,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" },