diff --git a/lab-python-flow-control.ipynb b/lab-python-flow-control.ipynb index f4c7391..913078d 100644 --- a/lab-python-flow-control.ipynb +++ b/lab-python-flow-control.ipynb @@ -37,11 +37,126 @@ "\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": "c6fa05a1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Tu lista de producto está vacío\n", + "Okey! Tu lista de compras es: {'keychain', 't-shirt', 'hat'}\n", + "Updated stock after order: {'t-shirt': 9, 'mug': 5, 'hat': 7, 'book': 4, 'keychain': 6}\n" + ] + } + ], + "source": [ + "\n", + "#EJERCICIO 2\n", + "\n", + "product_list = set() \n", + "\n", + "inventory = {\n", + " \"t-shirt\": 10,\n", + " \"mug\": 5,\n", + " \"hat\": 8,\n", + " \"book\": 4,\n", + " \"keychain\": 7}\n", + "\n", + "print(\"Tu lista de producto está vacío\") \n", + "\n", + "product = input (\"Dime que quieres comprar\") \n", + "\n", + "while product.lower() != \"\" and product.lower() != \"nada\": \n", + "\n", + " product_list.add(product.lower()) \n", + "\n", + " respuesta = input(\"Quires añadir otro producto?si/no\") \n", + "\n", + " if respuesta.lower() == \"si\": \n", + "\n", + " product = input(\"Que mas quieres añadir?\") \n", + "\n", + " elif respuesta.lower() == \"no\": \n", + "\n", + " break \n", + "\n", + " else: \n", + "\n", + " print(\"opcion no valida\") \n", + "\n", + "\n", + "print(\"Okey! Tu lista de compras es:\", product_list) \n", + "\n", + "#PARTE 3 DEL EJERCICIO\n", + "\n", + "for p in product_list:\n", + "\n", + " inventory[p] = inventory[p] - 1 \n", + "\n", + "print(\"Updated stock after order:\", inventory)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "89f47251", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "set()" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "product_list" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "76c74d58", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'nada'" + ] + }, + "execution_count": 9, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "product " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fb09da20", + "metadata": {}, + "outputs": [], + "source": [ + "\n" + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -55,7 +170,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.6" } }, "nbformat": 4,