From d9b86447c1e0da6f1ad8cfaa7bdef740f2e594e5 Mon Sep 17 00:00:00 2001 From: pietroguido90-design Date: Tue, 15 Sep 2026 14:37:56 +0100 Subject: [PATCH 1/3] Lab Data-structure Completed --- lab-python-data-structures.ipynb | 220 ++++++++++++++++++++++++++++++- 1 file changed, 218 insertions(+), 2 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 5b3ce9e0..20003d97 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -50,11 +50,227 @@ "\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": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for product in products:\n", + " num_str = input(f\"Enter quantity of {product}: \")\n", + " n_items = int(num_str)\n", + " inventory[product] = n_items" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 5, 'mug': 5, 'hat': 5, 'book': 5, 'keychain': 5}" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "inventory" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = set ()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for i in range(3):\n", + " order = input(\"Enter a product you want to order: \")\n", + " customer_orders.add(order)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'book', 'hat', 'mug'}" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "customer_orders" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "order = len(customer_orders)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "percentage_order = (order / sum(inventory.values())) * 100" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "order_status = (order, percentage_order)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "12.0" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "percentage_order" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "porder = str(percentage_order)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(3, 12.0)" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "order_status" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of Products Ordered: 12.0%\n" + ] + } + ], + "source": [ + "print(f\"\"\"Order Statistics:\n", + "Total Products Ordered: {order_status[0]}\n", + "Percentage of Products Ordered: {order_status[1]}%\"\"\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "for product in customer_orders:\n", + " inventory[product] -= 1" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "t-shirt: 5\n", + "mug: 4\n", + "hat: 4\n", + "book: 4\n", + "keychain: 5\n" + ] + } + ], + "source": [ + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\")" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": ".venv (3.14.6.final.0)", "language": "python", "name": "python3" }, @@ -68,7 +284,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.6" } }, "nbformat": 4, From f1c1aa44e5749ff0c4a0642dc126a8c6e9a023fc Mon Sep 17 00:00:00 2001 From: pietroguido90-design Date: Tue, 15 Sep 2026 16:16:09 +0100 Subject: [PATCH 2/3] LAB Flow Control Completed --- lab-python-data-structures.ipynb | 40 -------------------------------- 1 file changed, 40 deletions(-) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index 20003d97..f2b25a03 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -60,46 +60,6 @@ "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "inventory = {}" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "for product in products:\n", - " num_str = input(f\"Enter quantity of {product}: \")\n", - " n_items = int(num_str)\n", - " inventory[product] = n_items" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'t-shirt': 5, 'mug': 5, 'hat': 5, 'book': 5, 'keychain': 5}" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "inventory" - ] - }, { "cell_type": "code", "execution_count": null, From 062e76fe704d54c4f7e3ff3f0ae229f6db0963eb Mon Sep 17 00:00:00 2001 From: pietroguido90-design Date: Tue, 15 Sep 2026 16:30:25 +0100 Subject: [PATCH 3/3] LAB Data Structures Completed --- lab-python-data-structures.ipynb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lab-python-data-structures.ipynb b/lab-python-data-structures.ipynb index f2b25a03..74372046 100644 --- a/lab-python-data-structures.ipynb +++ b/lab-python-data-structures.ipynb @@ -226,6 +226,15 @@ "for product, quantity in inventory.items():\n", " print(f\"{product}: {quantity}\")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "asdsad" + ] } ], "metadata": {