diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..ddc7c9e 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,11 +37,93 @@ "\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": "672020b1", + "metadata": {}, + "outputs": [], + "source": [ + "#1 \n", + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory ={}\n", + "print (products)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "410f6542", + "metadata": {}, + "outputs": [], + "source": [ + "#1\n", + "#3 Exercise coming from lab-python-data-structures\n", + "for item in products:\n", + " value = int(input(f\"Enter the quantity for: {item}\"))\n", + "inventory [item] = value\n", + "print (inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "a8f58d78", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "38a88ce3", + "metadata": {}, + "outputs": [], + "source": [ + "#1\n", + "#5 Exercise \n", + "for i in range (3):\n", + " product= (input(f\"Enter name of product{i+1}:\"))\n", + " customer_orders.add(product)\n", + "print (customer_orders)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e6151ee8", + "metadata": {}, + "outputs": [], + "source": [ + "continue_ordering = \"yes\"\n", + "\n", + "while continue_ordering == \"yes\":\n", + " product_name = input(\"Enter product name:\")\n", + " set.add(product_name)\n", + " continue_ordering = input (\"do you want to add another product: (yes/no)\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cc0ff0b7", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = {}\n", + "\n", + "for i in customer_orders:\n", + " if i in inventory:" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -55,7 +137,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.2" } }, "nbformat": 4,