diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..642ff51 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.REPL.enableREPLSmartSend": false +} \ No newline at end of file diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..234c38d 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,11 +37,110 @@ "\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": 1, + "id": "5b52af72", + "metadata": {}, + "outputs": [], + "source": [ + "products = [\"t-shirt\", \"mug\", \"hat\", \"book\", \"keychain\"]" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "7d93b074", + "metadata": {}, + "outputs": [], + "source": [ + "inventory = {}" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "id": "b3aa0754", + "metadata": {}, + "outputs": [], + "source": [ + "for i in products:\n", + " inventory[i] = int(input(f\"Cuantas unidades necesita de {i}? \"))" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "1ffaf70b", + "metadata": {}, + "outputs": [], + "source": [ + "customer_orders = set()" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "id": "ce02d88b", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Gracias por su compra\n" + ] + } + ], + "source": [ + "continuar = \"yes\"\n", + "while continuar == \"yes\":\n", + " continuar = input(\"¿Quieres comprar un articulo? (yes/no): \").lower()\n", + " if continuar == \"yes\":\n", + " product = input(\"Ingrese el articulo: \")\n", + " if product in inventory:\n", + " customer_orders.add(product)\n", + " else:\n", + " print(\"Ese artículo no está en el inventario.\")\n", + " else:\n", + " print(\"Gracias por su compra\")" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "9d9541ca", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "{'mug', 'hat', 'book'}\n", + "{'t-shirt': 10, 'mug': 9, 'hat': 9, 'book': 9, 'keychain': 10}\n" + ] + } + ], + "source": [ + "for product in customer_orders:\n", + " inventory[product] -= 1\n", + "print(customer_orders)\n", + "print(inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e5c6f70b", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -55,7 +154,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.7" } }, "nbformat": 4,