diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..285e97c 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,11 +37,130 @@ "\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": 12, + "id": "af4c676c", + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]\n", + "inventory = {}\n", + "\n", + "for product in products:\n", + " quantity = int(input(f\"Enter quantity of {[product]}: \"))\n", + " inventory[product] = quantity\n", + "\n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "fa28dca9", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = set()\n", + "\n", + "while True:\n", + " product_order = input(\"Which product do you want to order?: \").lower()\n", + " customer_orders.add(product_order)\n", + " answer = input(\"Do you want to order another product? yes/no: \").lower()\n", + " if answer != \"yes\":\n", + " break\n", + "\n", + " \n", + "\n", + "\n" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "id": "b256bc36", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'t-shirt': 10, 'mug': 9, 'hat': 8, 'book': 10, 'keychain': 10}\n" + ] + } + ], + "source": [ + "for product in customer_orders:\n", + " inventory[product] -= 1\n", + "\n", + "print(inventory)\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f7a94670", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "d1a1382d", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "3385caf7", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "080202a6", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "de1ad654", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "778f53d4", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "97e13ff2", + "metadata": {}, + "outputs": [], + "source": [ + " \n", + "\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -55,7 +174,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.5" } }, "nbformat": 4,