From 8ad069f4127904fc171b18e623bf2ba2c6424028 Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Wed, 15 Apr 2026 12:20:48 +0200 Subject: [PATCH 1/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 205 ++++++++++++++++++++++++++++++++++++- 1 file changed, 203 insertions(+), 2 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 44d337b..1a1fbf6 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -43,11 +43,212 @@ "\n", "\n" ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "3e596b99", + "metadata": {}, + "outputs": [], + "source": [ + "def initialize_inventory(products):\n", + " inventory = {}\n", + " for item in products:\n", + " quantity = int(input(f\"Enter the quantity of {item} in inventory: \"))\n", + " inventory[item] = quantity\n", + " return inventory\n" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "3f6d1fe4", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 6, 'mug': 5}" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "initialize_inventory([\"t-shirt\", \"mug\"])" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "id": "5541d19e", + "metadata": {}, + "outputs": [], + "source": [ + "inv_dict = initialize_inventory([\"t-shirt\", \"mug\"])" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "3094bb82", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 6, 'mug': 8}" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "inv_dict" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "64708f8e", + "metadata": {}, + "outputs": [], + "source": [ + "continue_entering = 'yes'\n", + "\n", + "def get_customer_orders():\n", + " continue_entering = 'yes'\n", + " while continue_entering.lower() == 'yes':\n", + " customer_orders = ()\n", + " product_order = input('Enter the product you want to order: ')\n", + " customer_orders.add(product_order)\n", + " return customer_order" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "8cfe786c", + "metadata": {}, + "outputs": [], + "source": [ + "cust_set = get_customer_orders" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "3740d3bd", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cust_set" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "90685814", + "metadata": {}, + "outputs": [], + "source": [ + "def update_inventory(customer_orders, inventory):\n", + " for item in customer_orders:\n", + " if item in inventory:\n", + " inventory[item] -=1\n", + " \n", + " return inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "07623aa1", + "metadata": {}, + "outputs": [], + "source": [ + "update_inv = update_inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "7522eb5c", + "metadata": {}, + "outputs": [], + "source": [ + "def order_statistics(customer_orders, products):\n", + " total_set = len(customer_orders)\n", + " per_orderred = (total_set / len(products)) * 100\n", + " order_status = (total_set, per_orderred)\n", + " return order_status\n", + " \n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "615b19d7", + "metadata": {}, + "outputs": [], + "source": [ + "order_status = order_statistics" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "0902ec7c", + "metadata": {}, + "outputs": [], + "source": [ + "def print_order_statistics(order_statistics):\n", + " print(order_status)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "36deb386", + "metadata": {}, + "outputs": [], + "source": [ + "def print_updated_inventory(inventory):\n", + " for product in inventory:\n", + " inventory[product] -=1\n", + " print(print_updated_inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "id": "fd6bd5e1", + "metadata": {}, + "outputs": [], + "source": [ + "upd_inventory = print_updated_inventory" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -61,7 +262,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.4" } }, "nbformat": 4, From ff29bf959e75a96d980dc0fd28f945f1f420326b Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Wed, 15 Apr 2026 14:24:51 +0200 Subject: [PATCH 2/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 197 +++++++++++++++++++++++++++++-------- 1 file changed, 156 insertions(+), 41 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 1a1fbf6..f8e7942 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -46,32 +46,32 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "id": "3e596b99", "metadata": {}, "outputs": [], "source": [ "def initialize_inventory(products):\n", " inventory = {}\n", - " for item in products:\n", - " quantity = int(input(f\"Enter the quantity of {item} in inventory: \"))\n", - " inventory[item] = quantity\n", - " return inventory\n" + " for product in products:\n", + " quantity = int(input(f\"Enter the quantity of {product} in inventory: \"))\n", + " inventory[product] = quantity\n", + " return inventory" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 54, "id": "3f6d1fe4", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'t-shirt': 6, 'mug': 5}" + "{'t-shirt': 5, 'mug': 7}" ] }, - "execution_count": 4, + "execution_count": 54, "metadata": {}, "output_type": "execute_result" } @@ -82,66 +82,68 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 52, "id": "5541d19e", "metadata": {}, "outputs": [], "source": [ - "inv_dict = initialize_inventory([\"t-shirt\", \"mug\"])" + "inventory = initialize_inventory([\"t-shirt\", \"mug\"])" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 53, "id": "3094bb82", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'t-shirt': 6, 'mug': 8}" + "{'t-shirt': 5, 'mug': 8}" ] }, - "execution_count": 8, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "inv_dict" + "inventory" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 25, "id": "64708f8e", "metadata": {}, "outputs": [], "source": [ - "continue_entering = 'yes'\n", "\n", "def get_customer_orders():\n", + " customer_orders = set()\n", " continue_entering = 'yes'\n", " while continue_entering.lower() == 'yes':\n", - " customer_orders = ()\n", " product_order = input('Enter the product you want to order: ')\n", " customer_orders.add(product_order)\n", - " return customer_order" + "\n", + " continue_entering = input('Do you want to add another product? (yes/no)').lower()\n", + "\n", + " return customer_orders" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 55, "id": "8cfe786c", "metadata": {}, "outputs": [], "source": [ - "cust_set = get_customer_orders" + "cust_set = get_customer_orders()" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 27, "id": "3740d3bd", "metadata": {}, "outputs": [ @@ -151,7 +153,7 @@ "" ] }, - "execution_count": 4, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -162,7 +164,28 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 28, + "id": "7bdba33d", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'book', 'mug'}" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "get_customer_orders()" + ] + }, + { + "cell_type": "code", + "execution_count": 32, "id": "90685814", "metadata": {}, "outputs": [], @@ -170,14 +193,14 @@ "def update_inventory(customer_orders, inventory):\n", " for item in customer_orders:\n", " if item in inventory:\n", - " inventory[item] -=1\n", + " inventory[item] -= 1\n", " \n", " return inventory" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 33, "id": "07623aa1", "metadata": {}, "outputs": [], @@ -187,44 +210,94 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 36, + "id": "073c7b67", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 6, 'mug': 7}" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "update_inventory({'book', 'mug'}, {'t-shirt': 6, 'mug': 8} )" + ] + }, + { + "cell_type": "code", + "execution_count": null, "id": "7522eb5c", "metadata": {}, "outputs": [], "source": [ - "def order_statistics(customer_orders, products):\n", + "def calculate_order_statistics(customer_orders, products):\n", " total_set = len(customer_orders)\n", - " per_orderred = (total_set / len(products)) * 100\n", - " order_status = (total_set, per_orderred)\n", - " return order_status\n", - " \n" + " per_ordered = (total_set / len(products)) * 100\n", + " order_status = (total_set, per_ordered)\n", + " return order_status" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 38, "id": "615b19d7", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "(2, 100.0)" + ] + }, + "execution_count": 38, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "order_status = order_statistics" + "calculate_order_statistics({'book', 'mug'},[\"t-shirt\", \"mug\"])" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "id": "0902ec7c", "metadata": {}, "outputs": [], "source": [ "def print_order_statistics(order_statistics):\n", - " print(order_status)\n", + " # print the order statistics\n", + " print(calculate_order_statistics)\n", " " ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 42, + "id": "0055c57e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n" + ] + } + ], + "source": [ + "print_order_statistics((2, 100.0))" + ] + }, + { + "cell_type": "code", + "execution_count": 48, "id": "36deb386", "metadata": {}, "outputs": [], @@ -232,17 +305,59 @@ "def print_updated_inventory(inventory):\n", " for product in inventory:\n", " inventory[product] -=1\n", - " print(print_updated_inventory)" + " return inventory" ] }, { "cell_type": "code", - "execution_count": 13, - "id": "fd6bd5e1", + "execution_count": 49, + "id": "3ac98273", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 5, 'mug': 7}" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "print_updated_inventory({'t-shirt': 6, 'mug': 8})" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "id": "e956c3e5", "metadata": {}, "outputs": [], "source": [ - "upd_inventory = print_updated_inventory" + "def print_updated_inventory(inventory):\n", + " for product, quantity in inventory.items():\n", + " print(product, quantity)" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "id": "fd6bd5e1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "t-shirt 6\n", + "mug 8\n" + ] + } + ], + "source": [ + "print_updated_inventory({'t-shirt': 6, 'mug': 8})" ] } ], From 5da0c25a256f6c9e95665d87e21928f8a013bbc7 Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Wed, 15 Apr 2026 16:54:44 +0200 Subject: [PATCH 3/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 183 +++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 91 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index f8e7942..f4135ff 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 27, "id": "3e596b99", "metadata": {}, "outputs": [], @@ -61,7 +61,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 28, "id": "3f6d1fe4", "metadata": {}, "outputs": [ @@ -71,7 +71,7 @@ "{'t-shirt': 5, 'mug': 7}" ] }, - "execution_count": 54, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -82,8 +82,8 @@ }, { "cell_type": "code", - "execution_count": 52, - "id": "5541d19e", + "execution_count": 13, + "id": "87970022", "metadata": {}, "outputs": [], "source": [ @@ -92,8 +92,8 @@ }, { "cell_type": "code", - "execution_count": 53, - "id": "3094bb82", + "execution_count": 14, + "id": "49015d0d", "metadata": {}, "outputs": [ { @@ -102,7 +102,7 @@ "{'t-shirt': 5, 'mug': 8}" ] }, - "execution_count": 53, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -113,7 +113,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 15, "id": "64708f8e", "metadata": {}, "outputs": [], @@ -133,59 +133,38 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 16, "id": "8cfe786c", "metadata": {}, "outputs": [], "source": [ - "cust_set = get_customer_orders()" + "customer_orders = get_customer_orders()" ] }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 6, "id": "3740d3bd", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "cust_set" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "id": "7bdba33d", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'book', 'mug'}" + "{'keychain', 'mug'}" ] }, - "execution_count": 28, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "get_customer_orders()" + "customer_orders " ] }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 17, "id": "90685814", "metadata": {}, "outputs": [], @@ -200,53 +179,66 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 18, "id": "07623aa1", "metadata": {}, "outputs": [], "source": [ - "update_inv = update_inventory" + "inventory = update_inventory(customer_orders, inventory)\n" ] }, { "cell_type": "code", - "execution_count": 36, - "id": "073c7b67", + "execution_count": 19, + "id": "c063008c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'t-shirt': 6, 'mug': 7}" + "{'t-shirt': 5, 'mug': 7}" ] }, - "execution_count": 36, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "update_inventory({'book', 'mug'}, {'t-shirt': 6, 'mug': 8} )" + "inventory" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "7522eb5c", "metadata": {}, "outputs": [], "source": [ + "\n", "def calculate_order_statistics(customer_orders, products):\n", " total_set = len(customer_orders)\n", - " per_ordered = (total_set / len(products)) * 100\n", - " order_status = (total_set, per_ordered)\n", + " percentage_ordered = (total_set / len(products)) * 100\n", + " order_status = (total_set, percentage_ordered)\n", " return order_status" ] }, { "cell_type": "code", - "execution_count": 38, - "id": "615b19d7", + "execution_count": 29, + "id": "d880f5a9", + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\"]\n", + "order_statistics = calculate_order_statistics(customer_orders, products)\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "f8dc24f5", "metadata": {}, "outputs": [ { @@ -255,109 +247,118 @@ "(2, 100.0)" ] }, - "execution_count": 38, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "calculate_order_statistics({'book', 'mug'},[\"t-shirt\", \"mug\"])" + "order_statistics" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "id": "0902ec7c", "metadata": {}, "outputs": [], "source": [ "def print_order_statistics(order_statistics):\n", - " # print the order statistics\n", - " print(calculate_order_statistics)\n", + " print(order_statistics)\n", " " ] }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 20, "id": "0055c57e", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n" - ] + "data": { + "text/plain": [ + "(2, 100.0)" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "print_order_statistics((2, 100.0))" + "order_statistics" ] }, { "cell_type": "code", - "execution_count": 48, - "id": "36deb386", + "execution_count": 50, + "id": "e956c3e5", "metadata": {}, "outputs": [], "source": [ "def print_updated_inventory(inventory):\n", - " for product in inventory:\n", - " inventory[product] -=1\n", - " return inventory" + " for product, quantity in inventory.items():\n", + " print(product, quantity)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "fd6bd5e1", + "metadata": {}, + "outputs": [], + "source": [ + "inventory = print_updated_inventory(inventory)" ] }, { "cell_type": "code", - "execution_count": 49, - "id": "3ac98273", + "execution_count": 26, + "id": "2c1a7d9e", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'t-shirt': 5, 'mug': 7}" + "{'t-shirt': 3, 'mug': 6}" ] }, - "execution_count": 49, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "print_updated_inventory({'t-shirt': 6, 'mug': 8})" - ] - }, - { - "cell_type": "code", - "execution_count": 50, - "id": "e956c3e5", - "metadata": {}, - "outputs": [], - "source": [ - "def print_updated_inventory(inventory):\n", - " for product, quantity in inventory.items():\n", - " print(product, quantity)" + "inventory" ] }, { "cell_type": "code", - "execution_count": 51, - "id": "fd6bd5e1", + "execution_count": 31, + "id": "c025e669", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "t-shirt 6\n", - "mug 8\n" + "ename": "NameError", + "evalue": "name 'print_order_statistics' is not defined", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[31]\u001b[39m\u001b[32m, line 7\u001b[39m\n\u001b[32m 3\u001b[39m inventory = initialize_inventory(products)\n\u001b[32m 4\u001b[39m customer_orders = get_customer_orders()\n\u001b[32m 5\u001b[39m inventory = update_inventory(customer_orders, inventory)\n\u001b[32m 6\u001b[39m order_statistics = calculate_order_statistics(customer_orders, products)\n\u001b[32m----> \u001b[39m\u001b[32m7\u001b[39m print_order_statistics(order_statistics)\n\u001b[32m 8\u001b[39m print_updated_inventory(inventory)\n", + "\u001b[31mNameError\u001b[39m: name 'print_order_statistics' is not defined" ] } ], "source": [ - "print_updated_inventory({'t-shirt': 6, 'mug': 8})" + "products = [\"t-shirt\", \"mug\"]\n", + "\n", + "inventory = initialize_inventory(products)\n", + "customer_orders = get_customer_orders()\n", + "inventory = update_inventory(customer_orders, inventory)\n", + "order_statistics = calculate_order_statistics(customer_orders, products)\n", + "print_order_statistics(order_statistics)\n", + "print_updated_inventory(inventory)" ] } ], From e5d64e27e01c58b83741a1f5d738c2222e8e4734 Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Thu, 16 Apr 2026 15:41:31 +0200 Subject: [PATCH 4/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index f4135ff..c4c61ab 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -331,35 +331,6 @@ "source": [ "inventory" ] - }, - { - "cell_type": "code", - "execution_count": 31, - "id": "c025e669", - "metadata": {}, - "outputs": [ - { - "ename": "NameError", - "evalue": "name 'print_order_statistics' is not defined", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mNameError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[31]\u001b[39m\u001b[32m, line 7\u001b[39m\n\u001b[32m 3\u001b[39m inventory = initialize_inventory(products)\n\u001b[32m 4\u001b[39m customer_orders = get_customer_orders()\n\u001b[32m 5\u001b[39m inventory = update_inventory(customer_orders, inventory)\n\u001b[32m 6\u001b[39m order_statistics = calculate_order_statistics(customer_orders, products)\n\u001b[32m----> \u001b[39m\u001b[32m7\u001b[39m print_order_statistics(order_statistics)\n\u001b[32m 8\u001b[39m print_updated_inventory(inventory)\n", - "\u001b[31mNameError\u001b[39m: name 'print_order_statistics' is not defined" - ] - } - ], - "source": [ - "products = [\"t-shirt\", \"mug\"]\n", - "\n", - "inventory = initialize_inventory(products)\n", - "customer_orders = get_customer_orders()\n", - "inventory = update_inventory(customer_orders, inventory)\n", - "order_statistics = calculate_order_statistics(customer_orders, products)\n", - "print_order_statistics(order_statistics)\n", - "print_updated_inventory(inventory)" - ] } ], "metadata": { From 25211b5bb167cff66adc0aff0319a7426719b200 Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Thu, 16 Apr 2026 15:43:38 +0200 Subject: [PATCH 5/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 288 ------------------------------------- 1 file changed, 288 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index c4c61ab..5fa365a 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -43,294 +43,6 @@ "\n", "\n" ] - }, - { - "cell_type": "code", - "execution_count": 27, - "id": "3e596b99", - "metadata": {}, - "outputs": [], - "source": [ - "def initialize_inventory(products):\n", - " inventory = {}\n", - " for product in products:\n", - " quantity = int(input(f\"Enter the quantity of {product} in inventory: \"))\n", - " inventory[product] = quantity\n", - " return inventory" - ] - }, - { - "cell_type": "code", - "execution_count": 28, - "id": "3f6d1fe4", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'t-shirt': 5, 'mug': 7}" - ] - }, - "execution_count": 28, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "initialize_inventory([\"t-shirt\", \"mug\"])" - ] - }, - { - "cell_type": "code", - "execution_count": 13, - "id": "87970022", - "metadata": {}, - "outputs": [], - "source": [ - "inventory = initialize_inventory([\"t-shirt\", \"mug\"])" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "id": "49015d0d", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'t-shirt': 5, 'mug': 8}" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "inventory" - ] - }, - { - "cell_type": "code", - "execution_count": 15, - "id": "64708f8e", - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "def get_customer_orders():\n", - " customer_orders = set()\n", - " continue_entering = 'yes'\n", - " while continue_entering.lower() == 'yes':\n", - " product_order = input('Enter the product you want to order: ')\n", - " customer_orders.add(product_order)\n", - "\n", - " continue_entering = input('Do you want to add another product? (yes/no)').lower()\n", - "\n", - " return customer_orders" - ] - }, - { - "cell_type": "code", - "execution_count": 16, - "id": "8cfe786c", - "metadata": {}, - "outputs": [], - "source": [ - "customer_orders = get_customer_orders()" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "id": "3740d3bd", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'keychain', 'mug'}" - ] - }, - "execution_count": 6, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "customer_orders " - ] - }, - { - "cell_type": "code", - "execution_count": 17, - "id": "90685814", - "metadata": {}, - "outputs": [], - "source": [ - "def update_inventory(customer_orders, inventory):\n", - " for item in customer_orders:\n", - " if item in inventory:\n", - " inventory[item] -= 1\n", - " \n", - " return inventory" - ] - }, - { - "cell_type": "code", - "execution_count": 18, - "id": "07623aa1", - "metadata": {}, - "outputs": [], - "source": [ - "inventory = update_inventory(customer_orders, inventory)\n" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "c063008c", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'t-shirt': 5, 'mug': 7}" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "inventory" - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "7522eb5c", - "metadata": {}, - "outputs": [], - "source": [ - "\n", - "def calculate_order_statistics(customer_orders, products):\n", - " total_set = len(customer_orders)\n", - " percentage_ordered = (total_set / len(products)) * 100\n", - " order_status = (total_set, percentage_ordered)\n", - " return order_status" - ] - }, - { - "cell_type": "code", - "execution_count": 29, - "id": "d880f5a9", - "metadata": {}, - "outputs": [], - "source": [ - "products = [\"t-shirt\", \"mug\"]\n", - "order_statistics = calculate_order_statistics(customer_orders, products)\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 30, - "id": "f8dc24f5", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(2, 100.0)" - ] - }, - "execution_count": 30, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "order_statistics" - ] - }, - { - "cell_type": "code", - "execution_count": 19, - "id": "0902ec7c", - "metadata": {}, - "outputs": [], - "source": [ - "def print_order_statistics(order_statistics):\n", - " print(order_statistics)\n", - " " - ] - }, - { - "cell_type": "code", - "execution_count": 20, - "id": "0055c57e", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(2, 100.0)" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "order_statistics" - ] - }, - { - "cell_type": "code", - "execution_count": 50, - "id": "e956c3e5", - "metadata": {}, - "outputs": [], - "source": [ - "def print_updated_inventory(inventory):\n", - " for product, quantity in inventory.items():\n", - " print(product, quantity)" - ] - }, - { - "cell_type": "code", - "execution_count": 25, - "id": "fd6bd5e1", - "metadata": {}, - "outputs": [], - "source": [ - "inventory = print_updated_inventory(inventory)" - ] - }, - { - "cell_type": "code", - "execution_count": 26, - "id": "2c1a7d9e", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "{'t-shirt': 3, 'mug': 6}" - ] - }, - "execution_count": 26, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "inventory" - ] } ], "metadata": { From ae1c052af8566e71e64cdd8213c60e82ee916f91 Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Thu, 16 Apr 2026 16:35:32 +0200 Subject: [PATCH 6/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 261 +++++++++++++++++++++++++++++++++++++ 1 file changed, 261 insertions(+) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 5fa365a..bbd6737 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -43,6 +43,267 @@ "\n", "\n" ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "c774be30", + "metadata": {}, + "outputs": [], + "source": [ + "products = ['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "inventory = {}\n" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "d5f5ea21", + "metadata": {}, + "outputs": [], + "source": [ + "def initialize_inventory(products):\n", + " inventory = {}\n", + " for product in products: \n", + " quantity = int(input(f'Enter the quantity for {product}: ')) \n", + " inventory[product] = quantity\n", + " return inventory\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5b97158d", + "metadata": {}, + "outputs": [], + "source": [ + "inventory = initialize_inventory(products)" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "b01e35fa", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 5, 'mug': 6, 'hat': 8, 'book': 9, 'keychain': 10}\n" + ] + } + ], + "source": [ + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "3ae5ac79", + "metadata": {}, + "outputs": [], + "source": [ + "def get_customer_orders():\n", + " customer_orders = set()\n", + " for i in range(3):\n", + " product = input('Enter a product: ')\n", + " customer_orders.add(product)\n", + " return customer_orders" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "67b62d24", + "metadata": {}, + "outputs": [], + "source": [ + "orders = get_customer_orders()" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "id": "5ecd3dc5", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'mug', 'keychain', 'hat'}\n" + ] + } + ], + "source": [ + "print(orders)" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "13a1791e", + "metadata": {}, + "outputs": [], + "source": [ + "def updated_inventory(customer_orders, inventory):\n", + " for product in customer_orders:\n", + " inventory[product] -= 1\n", + " return inventory" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "26a277ae", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 5, 'mug': 5, 'hat': 6, 'book': 2, 'keychain': -1}\n" + ] + } + ], + "source": [ + "products = ['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "\n", + "orders = get_customer_orders()\n", + "\n", + "def update_inventory(customer_orders, inventory):\n", + " for product in customer_orders:\n", + " inventory[product] -= 1\n", + " return inventory\n", + "\n", + "updated_inventory_result = update_inventory(orders, inventory)\n", + "print(updated_inventory_result)" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "867942c5", + "metadata": {}, + "outputs": [], + "source": [ + "def calculate_order_statistics(customer_orders, products):\n", + " total_products_ordered = len(customer_orders)\n", + " percentage_ordered = (total_products_ordered / len(products)) * 100\n", + " return total_products_ordered, percentage_ordered" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "dc2e10ef", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(3, 60.0)\n" + ] + } + ], + "source": [ + "order_statistics = calculate_order_statistics(orders, products)\n", + "print(order_statistics)" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "a4a5383a", + "metadata": {}, + "outputs": [], + "source": [ + "def print_order_statistics(order_statistics):\n", + " total_products_ordered, percentage_ordered = order_statistics\n", + " \n", + " print(\"Order Statistics:\")\n", + " print(\"Total Products Ordered:\", total_products_ordered)\n", + " print(\"Percentage of Products Ordered:\", percentage_ordered, \"%\")" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "id": "9bd2b77f", + "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(order_statistics)" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "e9b973d9", + "metadata": {}, + "outputs": [], + "source": [ + "def print_updated_inventory(inventory):\n", + " for product in inventory:\n", + " print(product, \":\", inventory[product])" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "f8c46567", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "t-shirt : 5\n", + "mug : 5\n", + "hat : 6\n", + "book : 2\n", + "keychain : -1\n" + ] + } + ], + "source": [ + "print_updated_inventory(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "364edf52", + "metadata": {}, + "outputs": [], + "source": [ + "products = ['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", + "\n", + "inventory = initialize_inventory(products)\n", + "\n", + "orders = get_customer_orders()\n", + "\n", + "inventory = update_inventory(orders, inventory)\n", + "\n", + "print_updated_inventory(inventory)\n", + "\n", + "order_statistics = calculate_order_statistics(orders, products)\n", + "\n", + "print_order_statistics(order_statistics)" + ] } ], "metadata": { From 2b35018f0f4a76125a03e460fb9043df020301b9 Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Mon, 20 Apr 2026 11:13:33 +0200 Subject: [PATCH 7/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 221 ++++++++++++++++++++++--------------- 1 file changed, 132 insertions(+), 89 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index bbd6737..efc3e82 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -46,34 +46,33 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "c774be30", + "execution_count": 48, + "id": "84de27db", "metadata": {}, "outputs": [], "source": [ - "products = ['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", - "inventory = {}\n" + "products = ['t-shirt', 'mug', 'hat', 'book', 'keychain']" ] }, { "cell_type": "code", - "execution_count": 2, - "id": "d5f5ea21", + "execution_count": 49, + "id": "1550e364", "metadata": {}, "outputs": [], "source": [ "def initialize_inventory(products):\n", " inventory = {}\n", - " for product in products: \n", - " quantity = int(input(f'Enter the quantity for {product}: ')) \n", - " inventory[product] = quantity\n", - " return inventory\n" + " for product in products:\n", + " quantity = int(input(f'ENter the quantity for {product}: '))\n", + " inventory[product] = quantity\n", + " return inventory" ] }, { "cell_type": "code", - "execution_count": null, - "id": "5b97158d", + "execution_count": 50, + "id": "d6315653", "metadata": {}, "outputs": [], "source": [ @@ -82,26 +81,39 @@ }, { "cell_type": "code", - "execution_count": 9, - "id": "b01e35fa", + "execution_count": 51, + "id": "58039c2b", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'t-shirt': 5, 'mug': 6, 'hat': 8, 'book': 9, 'keychain': 10}\n" - ] + "data": { + "text/plain": [ + "{'t-shirt': 5, 'mug': 7, 'hat': 2, 'book': 6, 'keychain': 4}" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "print(inventory)" + "inventory" ] }, { "cell_type": "code", - "execution_count": 12, - "id": "3ae5ac79", + "execution_count": 52, + "id": "4561077c", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "4d374665", "metadata": {}, "outputs": [], "source": [ @@ -115,8 +127,8 @@ }, { "cell_type": "code", - "execution_count": 14, - "id": "67b62d24", + "execution_count": 54, + "id": "b77d62b6", "metadata": {}, "outputs": [], "source": [ @@ -125,26 +137,29 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "5ecd3dc5", + "execution_count": 55, + "id": "c1cbdaf5", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'mug', 'keychain', 'hat'}\n" - ] + "data": { + "text/plain": [ + "{'book', 'hat', 'mug'}" + ] + }, + "execution_count": 55, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "print(orders)" + "orders" ] }, { "cell_type": "code", - "execution_count": 21, - "id": "13a1791e", + "execution_count": 56, + "id": "8ab6880b", "metadata": {}, "outputs": [], "source": [ @@ -156,36 +171,39 @@ }, { "cell_type": "code", - "execution_count": 27, - "id": "26a277ae", + "execution_count": 57, + "id": "c01a0ff2", + "metadata": {}, + "outputs": [], + "source": [ + "inventory = updated_inventory(orders, inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "4b5a48a2", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'t-shirt': 5, 'mug': 5, 'hat': 6, 'book': 2, 'keychain': -1}\n" - ] + "data": { + "text/plain": [ + "{'t-shirt': 5, 'mug': 6, 'hat': 1, 'book': 5, 'keychain': 4}" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "products = ['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", - "\n", - "orders = get_customer_orders()\n", - "\n", - "def update_inventory(customer_orders, inventory):\n", - " for product in customer_orders:\n", - " inventory[product] -= 1\n", - " return inventory\n", - "\n", - "updated_inventory_result = update_inventory(orders, inventory)\n", - "print(updated_inventory_result)" + "inventory" ] }, { "cell_type": "code", - "execution_count": 29, - "id": "867942c5", + "execution_count": 59, + "id": "9a2e853a", "metadata": {}, "outputs": [], "source": [ @@ -197,42 +215,54 @@ }, { "cell_type": "code", - "execution_count": 30, - "id": "dc2e10ef", + "execution_count": 60, + "id": "11ba4bd0", + "metadata": {}, + "outputs": [], + "source": [ + "order_statistics = calculate_order_statistics(orders, products)" + ] + }, + { + "cell_type": "code", + "execution_count": 61, + "id": "59fda4ec", "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "(3, 60.0)\n" - ] + "data": { + "text/plain": [ + "(3, 60.0)" + ] + }, + "execution_count": 61, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "order_statistics = calculate_order_statistics(orders, products)\n", - "print(order_statistics)" + "order_statistics" ] }, { "cell_type": "code", - "execution_count": 31, - "id": "a4a5383a", + "execution_count": 62, + "id": "2c952292", "metadata": {}, "outputs": [], "source": [ "def print_order_statistics(order_statistics):\n", " total_products_ordered, percentage_ordered = order_statistics\n", - " \n", - " print(\"Order Statistics:\")\n", - " print(\"Total Products Ordered:\", total_products_ordered)\n", - " print(\"Percentage of Products Ordered:\", percentage_ordered, \"%\")" + "\n", + " print('Order Statistics:')\n", + " print('Total Products Ordered:', total_products_ordered)\n", + " print('Percentage of products Ordered:', percentage_ordered)" ] }, { "cell_type": "code", - "execution_count": 34, - "id": "9bd2b77f", + "execution_count": 63, + "id": "04f7388d", "metadata": {}, "outputs": [ { @@ -241,30 +271,30 @@ "text": [ "Order Statistics:\n", "Total Products Ordered: 3\n", - "Percentage of Products Ordered: 60.0 %\n" + "Percentage of products Ordered: 60.0\n" ] } ], "source": [ - "print_order_statistics(order_statistics)" + "print_order_statistics(order_statistics)\n" ] }, { "cell_type": "code", - "execution_count": 35, - "id": "e9b973d9", + "execution_count": 70, + "id": "47d12f2a", "metadata": {}, "outputs": [], "source": [ "def print_updated_inventory(inventory):\n", - " for product in inventory:\n", - " print(product, \":\", inventory[product])" + " for product in products:\n", + " print(product,\":\", inventory[product])" ] }, { "cell_type": "code", - "execution_count": 37, - "id": "f8c46567", + "execution_count": 71, + "id": "6009b4dc", "metadata": {}, "outputs": [ { @@ -272,10 +302,10 @@ "output_type": "stream", "text": [ "t-shirt : 5\n", - "mug : 5\n", - "hat : 6\n", - "book : 2\n", - "keychain : -1\n" + "mug : 6\n", + "hat : 1\n", + "book : 5\n", + "keychain : 4\n" ] } ], @@ -285,10 +315,23 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "364edf52", + "execution_count": 72, + "id": "8e5d2722", "metadata": {}, - "outputs": [], + "outputs": [ + { + "ename": "ValueError", + "evalue": "invalid literal for int() with base 10: ''", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[72]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m products = [\u001b[33m't-shirt'\u001b[39m, \u001b[33m'mug'\u001b[39m, \u001b[33m'hat'\u001b[39m, \u001b[33m'book'\u001b[39m, \u001b[33m'keychain'\u001b[39m]\n\u001b[32m 2\u001b[39m \n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m inventory = initialize_inventory(products)\n\u001b[32m 4\u001b[39m \n\u001b[32m 5\u001b[39m orders = get_customer_orders()\n\u001b[32m 6\u001b[39m \n", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[49]\u001b[39m\u001b[32m, line 4\u001b[39m, in \u001b[36minitialize_inventory\u001b[39m\u001b[34m(products)\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m initialize_inventory(products):\n\u001b[32m 2\u001b[39m inventory = {}\n\u001b[32m 3\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m product \u001b[38;5;28;01min\u001b[39;00m products:\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m quantity = int(input(f'ENter the quantity for {product}: '))\n\u001b[32m 5\u001b[39m inventory[product] = quantity\n\u001b[32m 6\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m inventory\n", + "\u001b[31mValueError\u001b[39m: invalid literal for int() with base 10: ''" + ] + } + ], "source": [ "products = ['t-shirt', 'mug', 'hat', 'book', 'keychain']\n", "\n", @@ -298,11 +341,11 @@ "\n", "inventory = update_inventory(orders, inventory)\n", "\n", - "print_updated_inventory(inventory)\n", - "\n", "order_statistics = calculate_order_statistics(orders, products)\n", "\n", - "print_order_statistics(order_statistics)" + "print_order_statistics(order_statistics)\n", + "\n", + "print_updated_inventory(inventory)" ] } ], From 02c421c05828b77ddc10cd1e57df80c2e71286ac Mon Sep 17 00:00:00 2001 From: roizherrerapilar-hub Date: Mon, 20 Apr 2026 11:43:42 +0200 Subject: [PATCH 8/8] Update lab-python-functions.ipynb --- lab-python-functions.ipynb | 98 +++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 48 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index efc3e82..76d7db1 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 17, "id": "84de27db", "metadata": {}, "outputs": [], @@ -56,7 +56,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 18, "id": "1550e364", "metadata": {}, "outputs": [], @@ -64,14 +64,14 @@ "def initialize_inventory(products):\n", " inventory = {}\n", " for product in products:\n", - " quantity = int(input(f'ENter the quantity for {product}: '))\n", + " quantity = int(input(f'Enter the quantity for {product}: '))\n", " inventory[product] = quantity\n", " return inventory" ] }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 19, "id": "d6315653", "metadata": {}, "outputs": [], @@ -81,17 +81,17 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 20, "id": "58039c2b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'t-shirt': 5, 'mug': 7, 'hat': 2, 'book': 6, 'keychain': 4}" + "{'t-shirt': 5, 'mug': 7, 'hat': 2, 'book': 8, 'keychain': 9}" ] }, - "execution_count": 51, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -102,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 21, "id": "4561077c", "metadata": {}, "outputs": [], @@ -112,7 +112,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 22, "id": "4d374665", "metadata": {}, "outputs": [], @@ -127,7 +127,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 23, "id": "b77d62b6", "metadata": {}, "outputs": [], @@ -137,7 +137,7 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 24, "id": "c1cbdaf5", "metadata": {}, "outputs": [ @@ -147,7 +147,7 @@ "{'book', 'hat', 'mug'}" ] }, - "execution_count": 55, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -158,12 +158,12 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 25, "id": "8ab6880b", "metadata": {}, "outputs": [], "source": [ - "def updated_inventory(customer_orders, inventory):\n", + "def update_inventory(customer_orders, inventory):\n", " for product in customer_orders:\n", " inventory[product] -= 1\n", " return inventory" @@ -171,27 +171,27 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 26, "id": "c01a0ff2", "metadata": {}, "outputs": [], "source": [ - "inventory = updated_inventory(orders, inventory)" + "inventory = update_inventory(orders, inventory)" ] }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 27, "id": "4b5a48a2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'t-shirt': 5, 'mug': 6, 'hat': 1, 'book': 5, 'keychain': 4}" + "{'t-shirt': 5, 'mug': 6, 'hat': 1, 'book': 7, 'keychain': 9}" ] }, - "execution_count": 58, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -202,20 +202,20 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 28, "id": "9a2e853a", "metadata": {}, "outputs": [], "source": [ "def calculate_order_statistics(customer_orders, products):\n", " total_products_ordered = len(customer_orders)\n", - " percentage_ordered = (total_products_ordered / len(products)) * 100\n", - " return total_products_ordered, percentage_ordered" + " percentage_of_unique_products_ordered = (total_products_ordered / len(products)) * 100\n", + " return total_products_ordered, percentage_of_unique_products_ordered" ] }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 29, "id": "11ba4bd0", "metadata": {}, "outputs": [], @@ -225,7 +225,7 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 30, "id": "59fda4ec", "metadata": {}, "outputs": [ @@ -235,7 +235,7 @@ "(3, 60.0)" ] }, - "execution_count": 61, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -246,22 +246,22 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 31, "id": "2c952292", "metadata": {}, "outputs": [], "source": [ "def print_order_statistics(order_statistics):\n", - " total_products_ordered, percentage_ordered = order_statistics\n", + " total_products_ordered, percentage_of_unique_products_ordered = order_statistics\n", "\n", " print('Order Statistics:')\n", " print('Total Products Ordered:', total_products_ordered)\n", - " print('Percentage of products Ordered:', percentage_ordered)" + " print('Percentage of unique products Ordered:', percentage_of_unique_products_ordered)" ] }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 32, "id": "04f7388d", "metadata": {}, "outputs": [ @@ -271,7 +271,7 @@ "text": [ "Order Statistics:\n", "Total Products Ordered: 3\n", - "Percentage of products Ordered: 60.0\n" + "Percentage of unique products Ordered: 60.0\n" ] } ], @@ -281,19 +281,19 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 33, "id": "47d12f2a", "metadata": {}, "outputs": [], "source": [ - "def print_updated_inventory(inventory):\n", - " for product in products:\n", + "def print_update_inventory(inventory):\n", + " for product in inventory:\n", " print(product,\":\", inventory[product])" ] }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 34, "id": "6009b4dc", "metadata": {}, "outputs": [ @@ -304,31 +304,33 @@ "t-shirt : 5\n", "mug : 6\n", "hat : 1\n", - "book : 5\n", - "keychain : 4\n" + "book : 7\n", + "keychain : 9\n" ] } ], "source": [ - "print_updated_inventory(inventory)" + "print_update_inventory(inventory)" ] }, { "cell_type": "code", - "execution_count": 72, + "execution_count": 35, "id": "8e5d2722", "metadata": {}, "outputs": [ { - "ename": "ValueError", - "evalue": "invalid literal for int() with base 10: ''", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[72]\u001b[39m\u001b[32m, line 3\u001b[39m\n\u001b[32m 1\u001b[39m products = [\u001b[33m't-shirt'\u001b[39m, \u001b[33m'mug'\u001b[39m, \u001b[33m'hat'\u001b[39m, \u001b[33m'book'\u001b[39m, \u001b[33m'keychain'\u001b[39m]\n\u001b[32m 2\u001b[39m \n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m inventory = initialize_inventory(products)\n\u001b[32m 4\u001b[39m \n\u001b[32m 5\u001b[39m orders = get_customer_orders()\n\u001b[32m 6\u001b[39m \n", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[49]\u001b[39m\u001b[32m, line 4\u001b[39m, in \u001b[36minitialize_inventory\u001b[39m\u001b[34m(products)\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m initialize_inventory(products):\n\u001b[32m 2\u001b[39m inventory = {}\n\u001b[32m 3\u001b[39m \u001b[38;5;28;01mfor\u001b[39;00m product \u001b[38;5;28;01min\u001b[39;00m products:\n\u001b[32m----> \u001b[39m\u001b[32m4\u001b[39m quantity = int(input(f'ENter the quantity for {product}: '))\n\u001b[32m 5\u001b[39m inventory[product] = quantity\n\u001b[32m 6\u001b[39m \u001b[38;5;28;01mreturn\u001b[39;00m inventory\n", - "\u001b[31mValueError\u001b[39m: invalid literal for int() with base 10: ''" + "name": "stdout", + "output_type": "stream", + "text": [ + "Order Statistics:\n", + "Total Products Ordered: 3\n", + "Percentage of unique products Ordered: 60.0\n", + "t-shirt : 5\n", + "mug : 7\n", + "hat : 4\n", + "book : 3\n", + "keychain : 3\n" ] } ], @@ -345,7 +347,7 @@ "\n", "print_order_statistics(order_statistics)\n", "\n", - "print_updated_inventory(inventory)" + "print_update_inventory(inventory)" ] } ],