diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..e395f5b 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -12,7 +12,7 @@ }, { "cell_type": "markdown", - "id": "3851fcd1-cf98-4653-9c89-e003b7ec9400", + "id": "1ada065a", "metadata": {}, "source": [ "## Exercise: Managing Customer Orders Optimized\n", @@ -37,6 +37,89 @@ "\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": "markdown", + "id": "1cb4fe5d", + "metadata": {}, + "source": [ + "Exercise 1:" + ] + }, + { + "cell_type": "markdown", + "id": "ce12ed23", + "metadata": {}, + "source": [ + "products = [\"t-shirt\", \"shoes\", \"gloves\", \"sueters\", \"jeans\"]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "883b656f", + "metadata": { + "vscode": { + "languageId": "plaintext" + } + }, + "outputs": [], + "source": [ + "inventory = {\n", + "\"t-shirt\" : 10, \n", + "\"shoes\" : 15,\n", + "\"gloves\" : 10,\n", + "\"sueters\" : 12,\n", + "\"jeans\" : 18\n", + "}\n", + "\n", + "customers_orders = set()" + ] + }, + { + "cell_type": "markdown", + "id": "4421e52d", + "metadata": {}, + "source": [ + "Exercise 2:" + ] + }, + { + "cell_type": "markdown", + "id": "e8e5e327", + "metadata": {}, + "source": [ + "while True: \n", + " product = input(\"Introduce the product that wants to order: \")\n", + "if product in products: \n", + " customers_orders.add(product)\n", + " print(f\"{product} add to your order\")\n", + "\n", + "else \n", + " print(\"This product does not exist\")\n", + "\n", + "another = input(\"Do you want to add a new product? (yes/no): \").lower ()\n", + "\n", + "if another == \"no\":\n", + "false" + ] + }, + { + "cell_type": "markdown", + "id": "7560eed8", + "metadata": {}, + "source": [ + "Exercise 3:" + ] + }, + { + "cell_type": "markdown", + "id": "e32596d9", + "metadata": {}, + "source": [ + "for product in customers_orders:\n", + " inventory [product] -=1" + ] } ], "metadata": {