From 66b84fc226ebad7b7639a0a0cc35b6245bbf4095 Mon Sep 17 00:00:00 2001 From: ConstanzaSegoviaA Date: Tue, 13 Jan 2026 16:41:55 +0100 Subject: [PATCH 1/4] tarea --- lab-python-functions.ipynb | 120 ++++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 2 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 44d337b..a291fee 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -43,11 +43,127 @@ "\n", "\n" ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "779c2b1d", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Productos disponibles: ['camiseta', 'taza', 'sombrero', 'libro', 'llavero']\n" + ] + } + ], + "source": [ + "productos=[\"camiseta\",\"taza\",\"sombrero\",\"libro\",\"llavero\"]\n", + "print(f\"Productos disponibles: {productos}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "id": "2c527b71", + "metadata": {}, + "outputs": [], + "source": [ + "def initialize_inventario(productos):\n", + " inventario = {}\n", + " for producto in productos:\n", + " cantidad = int(input(f\"Ingrese la cantidad de {producto} que desea agregar al inventario: \"))\n", + " inventario[producto] = cantidad\n", + " return inventario \n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "id": "67a2f4cf", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Inventario inicial: {'camiseta': 6, 'taza': 7, 'sombrero': 8, 'libro': 9, 'llavero': 1}\n" + ] + } + ], + "source": [ + "inventario = initialize_inventario(productos)\n", + "print(f\"Inventario inicial: {inventario}\")\n" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "877ba483", + "metadata": {}, + "outputs": [], + "source": [ + "def get_customer_ordes():\n", + " customer_orders=set()\n", + " \n", + " while True:\n", + " producto1 = input(f\"seleccione entre: {productos} ¿cual desea comprar? \")\n", + " customer_orders.add(producto1)\n", + " pedido=input(\"¿Desea agregar otro producto a su pedido? (si/no) \")\n", + " if pedido.lower() != 'si':\n", + " break\n", + " return customer_orders" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "723d5554", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "19c6f646", + "metadata": {}, + "outputs": [], + "source": [ + "while True:\n", + " producto1=input(f\"seleccione entre: {productos} ¿cual desea comprar? \")\n", + " customer_orders.append(producto1)\n", + " \n", + " pedido=input(\"¿Desea agregar otro producto a su pedido? (si/no) \")\n", + " if pedido.lower() != 'si':\n", + " break\n", + "print(\"Los productos en su pedido son:\", customer_orders)\n", + " " + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "275c5e0a", + "metadata": {}, + "outputs": [], + "source": [ + "for nombre in customer_orders:\n", + " cantidad = customer_orders.count(nombre)\n", + " \n", + " if nombre in inventario:\n", + " inventario[nombre] -= cantidad\n", + " print(f\"Cantidad restante en inventario: {inventario[nombre]} de {nombre}\")\n", + " else:\n", + " print(f\"{nombre} no está en el inventario.\") " + ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "Python 3", "language": "python", "name": "python3" }, @@ -61,7 +177,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.13.1" } }, "nbformat": 4, From 0e76b16a25efb41d97eb3190f12e5bc02c540abc Mon Sep 17 00:00:00 2001 From: ConstanzaSegoviaA Date: Tue, 13 Jan 2026 17:43:38 +0100 Subject: [PATCH 2/4] avance --- lab-python-functions.ipynb | 144 +++++++++++++++++++++++++++++-------- 1 file changed, 116 insertions(+), 28 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index a291fee..13d3d26 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 10, "id": "2c527b71", "metadata": {}, "outputs": [], @@ -81,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 11, "id": "67a2f4cf", "metadata": {}, "outputs": [ @@ -89,7 +89,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Inventario inicial: {'camiseta': 6, 'taza': 7, 'sombrero': 8, 'libro': 9, 'llavero': 1}\n" + "Inventario inicial: {'camiseta': 6, 'taza': 5, 'sombrero': 4, 'libro': 8, 'llavero': 7}\n" ] } ], @@ -100,65 +100,153 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": null, "id": "877ba483", "metadata": {}, "outputs": [], "source": [ - "def get_customer_ordes():\n", - " customer_orders=set()\n", + "def get_customer_orders():\n", + " customer.orders=set()\n", " \n", " while True:\n", " producto1 = input(f\"seleccione entre: {productos} ¿cual desea comprar? \")\n", - " customer_orders.add(producto1)\n", + " customer.orders.add(producto1)\n", " pedido=input(\"¿Desea agregar otro producto a su pedido? (si/no) \")\n", " if pedido.lower() != 'si':\n", " break\n", - " return customer_orders" + " return (customer.orders)" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "id": "723d5554", "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Productos comprados por el cliente: {'taza', 'libro'}\n" + ] + } + ], + "source": [ + "customer_orders = get_customer_orders()\n", + "print(f\"Productos comprados por el cliente: {customer_orders}\")" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "49c30238", + "metadata": {}, "outputs": [], - "source": [] + "source": [ + "def update_inventario(inventario, customer_orders):\n", + " for producto in customer_orders:\n", + " if producto in inventario and inventario[producto] > 0:\n", + " inventario[producto] -= 1\n", + " else:\n", + " print(f\"Lo siento, {producto} no está disponible en el inventario.\")\n", + " return inventario" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "315551a9", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Inventario actualizado: {'camiseta': 6, 'taza': 4, 'sombrero': 4, 'libro': 7, 'llavero': 7}\n" + ] + } + ], + "source": [ + "nuevo_inventario = update_inventario(inventario, customer_orders)\n", + "print(f\"Inventario actualizado: {nuevo_inventario}\")" + ] }, { "cell_type": "code", "execution_count": null, - "id": "19c6f646", + "id": "2c2f6820", "metadata": {}, "outputs": [], "source": [ - "while True:\n", - " producto1=input(f\"seleccione entre: {productos} ¿cual desea comprar? \")\n", - " customer_orders.append(producto1)\n", + "def calculate_order_statistics(customer_orders,inventario):\n", + " total_pedidos = len(customer_orders)\n", + " inventario_values = inventario.()\n", + " total_inventario = len(inventario_values)\n", + " porcentaje_comprados = (total_pedidos / total_inventario) * 100 \n", " \n", - " pedido=input(\"¿Desea agregar otro producto a su pedido? (si/no) \")\n", - " if pedido.lower() != 'si':\n", - " break\n", - "print(\"Los productos en su pedido son:\", customer_orders)\n", - " " + " return f\"se compran: {total_pedidos}, total de inventario: {total_inventario}, es el {porcentaje_comprados}%\"" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "id": "304ee1b8", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "se compran: 2, total de inventario: 5, es el 40.0%\n" + ] + } + ], + "source": [ + "estadistica=calculate_order_statistics(customer_orders,inventario)\n", + "print(estadistica)" ] }, { "cell_type": "code", "execution_count": null, - "id": "275c5e0a", + "id": "cd8acfbb", "metadata": {}, "outputs": [], "source": [ - "for nombre in customer_orders:\n", - " cantidad = customer_orders.count(nombre)\n", - " \n", - " if nombre in inventario:\n", - " inventario[nombre] -= cantidad\n", - " print(f\"Cantidad restante en inventario: {inventario[nombre]} de {nombre}\")\n", - " else:\n", - " print(f\"{nombre} no está en el inventario.\") " + "def print_order_statistics(order_statistics):\n", + " total_items, unique_items = order_statistics\n", + " print(f\"Total de artículos comprados: {total_items}\")\n", + " print(f\"Número de artículos únicos comprados: {unique_items}\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1aee4cef", + "metadata": {}, + "outputs": [], + "source": [ + "def print_updated_inventario(nuevo_inventario):\n", + " print(\"Inventario actualizado:\")\n", + " for producto, cantidad in nuevo_inventario.items():\n", + " print(f\"{producto}: {cantidad}\")" ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35efbea4", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "519ed3bc", + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From 28e16537f44c26f1d9e809e7f116b326ca03b456 Mon Sep 17 00:00:00 2001 From: ConstanzaSegoviaA Date: Wed, 14 Jan 2026 09:29:19 +0100 Subject: [PATCH 3/4] arreglo --- lab-python-functions.ipynb | 80 ++++++++++++++++++++++++++------------ 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 13d3d26..46c31d9 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 63, "id": "779c2b1d", "metadata": {}, "outputs": [ @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 64, "id": "2c527b71", "metadata": {}, "outputs": [], @@ -81,7 +81,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 65, "id": "67a2f4cf", "metadata": {}, "outputs": [ @@ -89,7 +89,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Inventario inicial: {'camiseta': 6, 'taza': 5, 'sombrero': 4, 'libro': 8, 'llavero': 7}\n" + "Inventario inicial: {'camiseta': 6, 'taza': 4, 'sombrero': 7, 'libro': 8, 'llavero': 1}\n" ] } ], @@ -100,26 +100,26 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 66, "id": "877ba483", "metadata": {}, "outputs": [], "source": [ "def get_customer_orders():\n", - " customer.orders=set()\n", + " customer_orders=set()\n", " \n", " while True:\n", - " producto1 = input(f\"seleccione entre: {productos} ¿cual desea comprar? \")\n", - " customer.orders.add(producto1)\n", - " pedido=input(\"¿Desea agregar otro producto a su pedido? (si/no) \")\n", - " if pedido.lower() != 'si':\n", + " product = input(\"¿Qué producto desea comprar? \")\n", + " customer_orders.add(product)\n", + " continuar = input(\"¿Desea agregar otro producto? (si/no): \")\n", + " if continuar.lower() != 'si':\n", " break\n", - " return (customer.orders)" + " return customer_orders" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 67, "id": "723d5554", "metadata": {}, "outputs": [ @@ -127,7 +127,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Productos comprados por el cliente: {'taza', 'libro'}\n" + "Productos comprados por el cliente: {'taza'}\n" ] } ], @@ -138,7 +138,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 68, "id": "49c30238", "metadata": {}, "outputs": [], @@ -154,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 69, "id": "315551a9", "metadata": {}, "outputs": [ @@ -162,7 +162,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Inventario actualizado: {'camiseta': 6, 'taza': 4, 'sombrero': 4, 'libro': 7, 'llavero': 7}\n" + "Inventario actualizado: {'camiseta': 6, 'taza': 3, 'sombrero': 7, 'libro': 8, 'llavero': 1}\n" ] } ], @@ -173,23 +173,24 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 73, "id": "2c2f6820", "metadata": {}, "outputs": [], "source": [ "def calculate_order_statistics(customer_orders,inventario):\n", " total_pedidos = len(customer_orders)\n", - " inventario_values = inventario.()\n", + "\n", + " inventario_values = inventario.values()\n", " total_inventario = len(inventario_values)\n", " porcentaje_comprados = (total_pedidos / total_inventario) * 100 \n", " \n", - " return f\"se compran: {total_pedidos}, total de inventario: {total_inventario}, es el {porcentaje_comprados}%\"" + " return (total_pedidos, total_inventario, porcentaje_comprados)" ] }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 74, "id": "304ee1b8", "metadata": {}, "outputs": [ @@ -197,7 +198,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "se compran: 2, total de inventario: 5, es el 40.0%\n" + "(1, 5, 20.0)\n" ] } ], @@ -208,15 +209,44 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 58, "id": "cd8acfbb", "metadata": {}, "outputs": [], "source": [ "def print_order_statistics(order_statistics):\n", - " total_items, unique_items = order_statistics\n", - " print(f\"Total de artículos comprados: {total_items}\")\n", - " print(f\"Número de artículos únicos comprados: {unique_items}\")" + " print(f\"Total de productos pedidos: {order_statistics[0]}\")\n", + " print(f\"Porcentaje de productos únicos pedidos: {order_statistics[1]:.2f}%\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f7a916e7", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Total de productos pedidos: s\n" + ] + }, + { + "ename": "ValueError", + "evalue": "Unknown format code 'f' for object of type 'str'", + "output_type": "error", + "traceback": [ + "\u001b[31m---------------------------------------------------------------------------\u001b[39m", + "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[59]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m resp=\u001b[43mprint_order_statistics\u001b[49m\u001b[43m(\u001b[49m\u001b[43mestadistica\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[58]\u001b[39m\u001b[32m, line 3\u001b[39m, in \u001b[36mprint_order_statistics\u001b[39m\u001b[34m(order_statistics)\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mprint_order_statistics\u001b[39m(order_statistics):\n\u001b[32m 2\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mTotal de productos pedidos: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00morder_statistics[\u001b[32m0\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mPorcentaje de productos únicos pedidos: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00morder_statistics[\u001b[32m1\u001b[39m]\u001b[38;5;132;01m:\u001b[39;00m\u001b[33m.2f\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m%\u001b[39m\u001b[33m\"\u001b[39m)\n", + "\u001b[31mValueError\u001b[39m: Unknown format code 'f' for object of type 'str'" + ] + } + ], + "source": [ + "resp=print_order_statistics()\n" ] }, { From 16cc050d43a72c2d9dc9d90ae079ac060a8955b9 Mon Sep 17 00:00:00 2001 From: ConstanzaSegoviaA Date: Wed, 14 Jan 2026 13:56:02 +0100 Subject: [PATCH 4/4] ok --- lab-python-functions.ipynb | 172 +++++++++---------------------------- 1 file changed, 39 insertions(+), 133 deletions(-) diff --git a/lab-python-functions.ipynb b/lab-python-functions.ipynb index 46c31d9..be3eb6b 100644 --- a/lab-python-functions.ipynb +++ b/lab-python-functions.ipynb @@ -46,7 +46,7 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 1, "id": "779c2b1d", "metadata": {}, "outputs": [ @@ -65,7 +65,7 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 2, "id": "2c527b71", "metadata": {}, "outputs": [], @@ -81,26 +81,7 @@ }, { "cell_type": "code", - "execution_count": 65, - "id": "67a2f4cf", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Inventario inicial: {'camiseta': 6, 'taza': 4, 'sombrero': 7, 'libro': 8, 'llavero': 1}\n" - ] - } - ], - "source": [ - "inventario = initialize_inventario(productos)\n", - "print(f\"Inventario inicial: {inventario}\")\n" - ] - }, - { - "cell_type": "code", - "execution_count": 66, + "execution_count": 3, "id": "877ba483", "metadata": {}, "outputs": [], @@ -119,27 +100,8 @@ }, { "cell_type": "code", - "execution_count": 67, - "id": "723d5554", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Productos comprados por el cliente: {'taza'}\n" - ] - } - ], - "source": [ - "customer_orders = get_customer_orders()\n", - "print(f\"Productos comprados por el cliente: {customer_orders}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 68, - "id": "49c30238", + "execution_count": 4, + "id": "ca45f0dc", "metadata": {}, "outputs": [], "source": [ @@ -154,129 +116,73 @@ }, { "cell_type": "code", - "execution_count": 69, - "id": "315551a9", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Inventario actualizado: {'camiseta': 6, 'taza': 3, 'sombrero': 7, 'libro': 8, 'llavero': 1}\n" - ] - } - ], - "source": [ - "nuevo_inventario = update_inventario(inventario, customer_orders)\n", - "print(f\"Inventario actualizado: {nuevo_inventario}\")" - ] - }, - { - "cell_type": "code", - "execution_count": 73, + "execution_count": 5, "id": "2c2f6820", "metadata": {}, "outputs": [], "source": [ - "def calculate_order_statistics(customer_orders,inventario):\n", + "def calculate_order_statistics(customer_orders, productos):\n", " total_pedidos = len(customer_orders)\n", - "\n", - " inventario_values = inventario.values()\n", - " total_inventario = len(inventario_values)\n", - " porcentaje_comprados = (total_pedidos / total_inventario) * 100 \n", - " \n", - " return (total_pedidos, total_inventario, porcentaje_comprados)" + " porcentaje_comprados = (total_pedidos / len(productos)) * 100\n", + " return total_pedidos, porcentaje_comprados" ] }, { "cell_type": "code", - "execution_count": 74, - "id": "304ee1b8", + "execution_count": 8, + "id": "cd8acfbb", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "(1, 5, 20.0)\n" - ] - } - ], + "outputs": [], "source": [ - "estadistica=calculate_order_statistics(customer_orders,inventario)\n", - "print(estadistica)" + "def print_order_statistics(order_statistics):\n", + " print(f\"Total de productos pedidos: {order_statistics[0]}\")\n", + " print(f\"Porcentaje de productos únicos pedidos: {order_statistics[1]:.2f}%\")" ] }, { "cell_type": "code", - "execution_count": 58, - "id": "cd8acfbb", + "execution_count": 9, + "id": "f7a916e7", "metadata": {}, "outputs": [], "source": [ - "def print_order_statistics(order_statistics):\n", - " print(f\"Total de productos pedidos: {order_statistics[0]}\")\n", - " print(f\"Porcentaje de productos únicos pedidos: {order_statistics[1]:.2f}%\")" + "def print_updated_inventario(nuevo_inventario):\n", + " print(\"Inventario actualizado:\")\n", + " for producto, cantidad in nuevo_inventario.items():\n", + " print(f\"{producto}: {cantidad}\")\n" ] }, { "cell_type": "code", - "execution_count": null, - "id": "f7a916e7", + "execution_count": 10, + "id": "1aee4cef", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "Total de productos pedidos: s\n" - ] - }, - { - "ename": "ValueError", - "evalue": "Unknown format code 'f' for object of type 'str'", - "output_type": "error", - "traceback": [ - "\u001b[31m---------------------------------------------------------------------------\u001b[39m", - "\u001b[31mValueError\u001b[39m Traceback (most recent call last)", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[59]\u001b[39m\u001b[32m, line 1\u001b[39m\n\u001b[32m----> \u001b[39m\u001b[32m1\u001b[39m resp=\u001b[43mprint_order_statistics\u001b[49m\u001b[43m(\u001b[49m\u001b[43mestadistica\u001b[49m\u001b[43m)\u001b[49m\n", - "\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[58]\u001b[39m\u001b[32m, line 3\u001b[39m, in \u001b[36mprint_order_statistics\u001b[39m\u001b[34m(order_statistics)\u001b[39m\n\u001b[32m 1\u001b[39m \u001b[38;5;28;01mdef\u001b[39;00m\u001b[38;5;250m \u001b[39m\u001b[34mprint_order_statistics\u001b[39m(order_statistics):\n\u001b[32m 2\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mTotal de productos pedidos: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00morder_statistics[\u001b[32m0\u001b[39m]\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m)\n\u001b[32m----> \u001b[39m\u001b[32m3\u001b[39m \u001b[38;5;28mprint\u001b[39m(\u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mPorcentaje de productos únicos pedidos: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00morder_statistics[\u001b[32m1\u001b[39m]\u001b[38;5;132;01m:\u001b[39;00m\u001b[33m.2f\u001b[39m\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m%\u001b[39m\u001b[33m\"\u001b[39m)\n", - "\u001b[31mValueError\u001b[39m: Unknown format code 'f' for object of type 'str'" + "Lo siento, 1 no está disponible en el inventario.\n", + "Total de productos pedidos: 1\n", + "Porcentaje de productos únicos pedidos: 20.00%\n", + "Inventario actualizado:\n", + "camiseta: 6\n", + "taza: 8\n", + "sombrero: 4\n", + "libro: 7\n", + "llavero: 5\n" ] } ], "source": [ - "resp=print_order_statistics()\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "1aee4cef", - "metadata": {}, - "outputs": [], - "source": [ - "def print_updated_inventario(nuevo_inventario):\n", - " print(\"Inventario actualizado:\")\n", - " for producto, cantidad in nuevo_inventario.items():\n", - " print(f\"{producto}: {cantidad}\")" + "productos = [\"camiseta\", \"taza\", \"sombrero\", \"libro\", \"llavero\"]\n", + "inventario = initialize_inventario(productos)\n", + "customer_orders = get_customer_orders()\n", + "inventario = update_inventario(inventario, customer_orders)\n", + "estadisticas = calculate_order_statistics(customer_orders, productos)\n", + "print_order_statistics(estadisticas)\n", + "print_updated_inventario(inventario)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "35efbea4", - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "519ed3bc", - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {