From c59a4d2609f414cdb8c87dc1e389398a211df429 Mon Sep 17 00:00:00 2001 From: Orgo4ever <163662002+Orgo4ever@users.noreply.github.com> Date: Tue, 16 Jun 2026 17:24:33 +0200 Subject: [PATCH 1/2] Solved lab 2 This is the adjustments to the first lab to complete the second one. --- lab-python-flow-control.ipynb | 176 ++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..12041b8 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,6 +37,182 @@ "\n", "3. Instead of updating the inventory by subtracting 1 from the quantity of each product, only do it for the products that were ordered (those in \"customer_orders\")." ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6b2efcf0", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "#This is Kyle Solving the Lab\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5b65ea77", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "products=[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e94cae12", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "inventory={}" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "594de533", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "for product in products:\n", + " quantity = int(input(f\"Enter the quantity of {product}: \"))\n", + " inventory[product] = quantity\n", + "\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "69d10e9e", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "customer_orders=set()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "5c8aee42", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "while True:\n", + " product_order = input(\"Enter the name of a product: \")\n", + "\n", + " if product_order in products:\n", + " customer_orders.add(product_order)\n", + " else:\n", + " print(\"That product is not available.\")\n", + "\n", + " add_another = input(\"Do you want to add another product? (yes/no): \")\n", + "\n", + " if add_another.lower() == \"no\":\n", + " break" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "7bfed850", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "print(customer_orders)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f36032f3", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "total_products_ordered=len(customer_orders)\n", + "print(total_products_ordered)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b2b04ae9", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "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, + "id": "99832692", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "order_status=(total_products_ordered, percentage_ordered)\n", + "print(order_status)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a2488feb", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "for product in customer_orders:\n", + " inventory[product] = inventory[product] - 1 \n", + "\n", + "for product, quantity in inventory.items():\n", + " print(f\"{product}: {quantity}\")\n" + ] } ], "metadata": { From 19c369e5a426440a10f6e219b1824eb53966093d Mon Sep 17 00:00:00 2001 From: Orgo4ever <163662002+Orgo4ever@users.noreply.github.com> Date: Sun, 5 Jul 2026 07:35:46 +0200 Subject: [PATCH 2/2] Update lab-python-flow-control.ipynb Update to lab for practice --- lab-python-flow-control.ipynb | 183 +++++++++++++--------------------- 1 file changed, 69 insertions(+), 114 deletions(-) diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index 12041b8..bf3620c 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -40,13 +40,9 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 17, "id": "6b2efcf0", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "metadata": {}, "outputs": [], "source": [ "#This is Kyle Solving the Lab\n" @@ -54,27 +50,19 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "5b65ea77", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "execution_count": 18, + "id": "0642ca8f", + "metadata": {}, "outputs": [], "source": [ - "products=[\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n" + "products= [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" ] }, { "cell_type": "code", - "execution_count": null, - "id": "e94cae12", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "execution_count": 19, + "id": "ceaf2fba", + "metadata": {}, "outputs": [], "source": [ "inventory={}" @@ -82,142 +70,109 @@ }, { "cell_type": "code", - "execution_count": null, - "id": "594de533", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "execution_count": 20, + "id": "ae3eaf53", + "metadata": {}, "outputs": [], "source": [ - "for product in products:\n", - " quantity = int(input(f\"Enter the quantity of {product}: \"))\n", - " inventory[product] = quantity\n", + "inventory = {}\n", "\n", - "print(inventory)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "69d10e9e", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, - "outputs": [], - "source": [ - "customer_orders=set()" + "for product in products:\n", + " inventory[product] = int(input(f\"Input number of {product}: \"))" ] }, { "cell_type": "code", - "execution_count": null, - "id": "5c8aee42", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "execution_count": 21, + "id": "aef93432", + "metadata": {}, "outputs": [], "source": [ - "while True:\n", - " product_order = input(\"Enter the name of a product: \")\n", - "\n", - " if product_order in products:\n", - " customer_orders.add(product_order)\n", - " else:\n", - " print(\"That product is not available.\")\n", - "\n", - " add_another = input(\"Do you want to add another product? (yes/no): \")\n", - "\n", - " if add_another.lower() == \"no\":\n", - " break" + "customer_orders= set()" ] }, { "cell_type": "code", - "execution_count": null, - "id": "7bfed850", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "execution_count": 22, + "id": "d97e7347", + "metadata": {}, "outputs": [], "source": [ - "print(customer_orders)\n" + "order= input(\"select a product to order:\")\n", + "customer_orders.add(order)" ] }, { "cell_type": "code", - "execution_count": null, - "id": "f36032f3", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "execution_count": 23, + "id": "a1b11680", + "metadata": {}, "outputs": [], "source": [ - "total_products_ordered=len(customer_orders)\n", - "print(total_products_ordered)" + "continue_order= input(\"would you like to order another product?:\")" ] }, { "cell_type": "code", - "execution_count": null, - "id": "b2b04ae9", - "metadata": { - "vscode": { - "languageId": "plaintext" + "execution_count": 24, + "id": "cd589653", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Thank you, your order(s) have been ordered.\n" + ] } - }, - "outputs": [], + ], "source": [ - "percentage_ordered = (len(customer_orders) / len(products)) * 100\n", - "print(f\"percentage of products ordered: {percentage_ordered}%\")" + "continue_order = \"yes\"\n", + "\n", + "while continue_order == \"yes\":\n", + " order = input(\"Select a product to order: \")\n", + " customer_orders.add(order)\n", + " continue_order = input(\"Would you like to order another product? yes/no: \").lower()\n", + "\n", + "print(\"Thank you, your order(s) have been ordered.\")\n" ] }, { "cell_type": "code", - "execution_count": null, - "id": "99832692", - "metadata": { - "vscode": { - "languageId": "plaintext" - } - }, + "execution_count": 26, + "id": "087e0960", + "metadata": {}, "outputs": [], "source": [ - "order_status=(total_products_ordered, percentage_ordered)\n", - "print(order_status)\n" + "for product in customer_orders:\n", + " inventory[product] = inventory[product] - 1\n" ] }, { "cell_type": "code", - "execution_count": null, - "id": "a2488feb", - "metadata": { - "vscode": { - "languageId": "plaintext" + "execution_count": 27, + "id": "44eb4829", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'t-shirt': 5, 'mug': 4, 'hat': 5, 'book': 4, 'keychain': 5}" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" } - }, - "outputs": [], + ], "source": [ - "for product in customer_orders:\n", - " inventory[product] = inventory[product] - 1 \n", - "\n", - "for product, quantity in inventory.items():\n", - " print(f\"{product}: {quantity}\")\n" + "inventory" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -231,7 +186,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.9.10" } }, "nbformat": 4,