From 6839f5f6499dae24f28aba325d3db4bf98ff5098 Mon Sep 17 00:00:00 2001 From: Orgo4ever <163662002+Orgo4ever@users.noreply.github.com> Date: Tue, 16 Jun 2026 16:32:31 +0200 Subject: [PATCH 1/2] Update lab-python-data-structures.ipynb Completion of lab 1 --- lab-python-data-structures.ipynb | 166 ++++++++++++++++++++++++++++++- 1 file changed, 164 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..f7d63518 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,173 @@ "\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": null, + "metadata": {}, + "outputs": [], + "source": [ + "# This is Kyle Solving the Lab" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "products=[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "inventory={}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Ask for product inventory\n", + "inventory[\"t-shirt\"] = int(input(\"Enter the quantity of t-shirt: \"))\n", + "inventory[\"mug\"] = int(input(\"Enter the quantity of mug: \"))\n", + "inventory[\"hat\"] = int(input(\"Enter the quantity of hat: \"))\n", + "inventory[\"book\"] = int(input(\"Enter the quantity of book: \"))\n", + "inventory[\"keychain\"] = int(input(\"Enter the quantity of keychain: \"))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders=set()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Ask for orders\n", + "product_order_1 = input(\"Enter the first product: \")\n", + "product_order_2 = input(\"Enter the second product: \")\n", + "product_order_3 = input(\"Enter the third product: \")\n", + "customer_orders.add(product_order_1)\n", + "customer_orders.add(product_order_2)\n", + "customer_orders.add(product_order_3)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(customer_orders)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "percentage_ordered = (len(customer_orders) / len(products)) * 100\n", + "print(f\"percentage of products ordered: {percentage_ordered}%\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "order_status=(total_products_ordered, percentage_ordered)\n", + "print(order_status)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Memory update\n", + "inventory[product_order_1] = inventory[product_order_1] - 1\n", + "inventory[product_order_2] = inventory[product_order_2] - 1\n", + "inventory[product_order_3] = inventory[product_order_3] - 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Inventory update\n", + "print(f\"t-shirt: {inventory['t-shirt']}\")\n", + "print(f\"mug: {inventory['mug']}\")\n", + "print(f\"hat: {inventory['hat']}\")\n", + "print(f\"book: {inventory['book']}\")\n", + "print(f\"keychain: {inventory['keychain']}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -68,7 +230,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.10.4" } }, "nbformat": 4, From ac00b5cdc2a6207138c62abed79621df8d9fa98d Mon Sep 17 00:00:00 2001 From: Orgo4ever <163662002+Orgo4ever@users.noreply.github.com> Date: Sun, 5 Jul 2026 06:36:48 +0200 Subject: [PATCH 2/2] Update lab-python-data-structures.ipynb Rework of lab for practice --- lab-python-data-structures.ipynb | 161 ++++++++++++++++++++++--------- 1 file changed, 115 insertions(+), 46 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index f7d63518..7c1759fa 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -53,7 +53,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 61, "metadata": {}, "outputs": [], "source": [ @@ -62,16 +62,16 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 62, "metadata": {}, "outputs": [], "source": [ - "products=[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n" + "products= [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 63, "metadata": {}, "outputs": [], "source": [ @@ -80,49 +80,129 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 64, "metadata": {}, "outputs": [], "source": [ - "# Ask for product inventory\n", - "inventory[\"t-shirt\"] = int(input(\"Enter the quantity of t-shirt: \"))\n", - "inventory[\"mug\"] = int(input(\"Enter the quantity of mug: \"))\n", - "inventory[\"hat\"] = int(input(\"Enter the quantity of hat: \"))\n", - "inventory[\"book\"] = int(input(\"Enter the quantity of book: \"))\n", - "inventory[\"keychain\"] = int(input(\"Enter the quantity of keychain: \"))" + "t_shirt_quantity=int(input(\"Enter the quantity of t-shirsts:\"))\n", + "mug_quantity=int(input(\"Enter the quantity of mugs:\"))\n", + "hat_quantity=int(input(\"Enter the quantity of hats:\"))\n", + "book_quantity=int(input(\"Enter the quantity of mugs:\"))\n", + "keychain_quantity=int(input(\"Enter the quantity of keychains:\"))" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 65, "metadata": {}, "outputs": [], "source": [ - "customer_orders=set()" + "inventory={\"t-shirt\": t_shirt_quantity, \n", + "\"mug\": mug_quantity, \n", + "\"hat\": hat_quantity, \n", + "\"book\": book_quantity, \n", + "\"keychain\": keychain_quantity }" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 5, 'mug': 5, 'hat': 5, 'book': 5, 'keychain': 5}" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 67, "metadata": {}, "outputs": [], "source": [ - "# Ask for orders\n", - "product_order_1 = input(\"Enter the first product: \")\n", - "product_order_2 = input(\"Enter the second product: \")\n", - "product_order_3 = input(\"Enter the third product: \")\n", - "customer_orders.add(product_order_1)\n", - "customer_orders.add(product_order_2)\n", - "customer_orders.add(product_order_3)" + "customer_orders={}" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 68, "metadata": {}, "outputs": [], "source": [ - "print(customer_orders)\n" + "order_1=input(\"Please enter a product to order:\")\n", + "order_2= input(\"Please enter a product to order:\")\n", + "order_3=input(\"Please enter a product to order:\")\n", + "order_= input(\"Please enter a product to order:\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'mug', 'keychain', 'hat'}\n" + ] + } + ], + "source": [ + "customer_orders={order_1, order_2, order_3}\n", + "print(customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 70, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(3, 60.0)\n" + ] + } + ], + "source": [ + "products_ordered= len(customer_orders)\n", + "percentage_ordered= len(customer_orders)/len(products)*100\n", + "order_statistics=(products_ordered, percentage_ordered,)\n", + "print(order_statistics)" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 3, 'mug': 3, 'hat': 3, 'book': 3, 'keychain': 3}\n" + ] + } + ], + "source": [ + "inventory[\"t-shirt\"]=inventory[\"t-shirt\"]-1\n", + "inventory[\"mug\"]=inventory[\"mug\"]-1\n", + "inventory[\"book\"]=inventory[\"book\"]-1\n", + "inventory[\"hat\"]=inventory[\"hat\"]-1\n", + "inventory[\"keychain\"]=inventory[\"keychain\"]-1\n", + "print(inventory)" ] }, { @@ -137,10 +217,7 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "percentage_ordered = (len(customer_orders) / len(products)) * 100\n", - "print(f\"percentage of products ordered: {percentage_ordered}%\")" - ] + "source": [] }, { "cell_type": "code", @@ -154,36 +231,28 @@ "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "order_status=(total_products_ordered, percentage_ordered)\n", - "print(order_status)\n" - ] + "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "# Memory update\n", - "inventory[product_order_1] = inventory[product_order_1] - 1\n", - "inventory[product_order_2] = inventory[product_order_2] - 1\n", - "inventory[product_order_3] = inventory[product_order_3] - 1" - ] + "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "# Inventory update\n", - "print(f\"t-shirt: {inventory['t-shirt']}\")\n", - "print(f\"mug: {inventory['mug']}\")\n", - "print(f\"hat: {inventory['hat']}\")\n", - "print(f\"book: {inventory['book']}\")\n", - "print(f\"keychain: {inventory['keychain']}\")" - ] + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] }, { "cell_type": "code", @@ -230,7 +299,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.4" + "version": "3.9.10" } }, "nbformat": 4,