From 999c439a047c5f739de9e8c61471c9516682bc80 Mon Sep 17 00:00:00 2001 From: Juan Carlos Del Mar Lostanau <147656412+Juancarlosdelmarlostanau@users.noreply.github.com> Date: Sat, 19 Sep 2026 14:22:04 +0200 Subject: [PATCH 1/2] Update cfu-data-types.ipynb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit solución 1 --- cfu-data-types.ipynb | 174 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 150 insertions(+), 24 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index e0fee02..bf518bb 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -32,28 +32,106 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "In this exercise, prompt the user to enter their personal information such as name, age, address, salary, and expenses, and then perform some calculations to determine how much money they have left after expenses. \n", + "En este ejercicio, pida al usuario que ingrese su información personal, como nombre, edad, dirección, salario y gastos, y luego realice algunos cálculos para determinar cuánto dinero le queda después de los gastos. \n", "\n", - "Use data type casting to ensure that the age, salary, and expenses are stored as integers or floats, as appropriate, and round the remaining money to one decimal. \n", + "Utilice la conversión de tipos de datos para garantizar que la edad, el salario y los gastos se almacenen como números enteros o flotantes, según corresponda, y redondee el resto a un decimal. \n", "\n", - "Use a boolean variable to indicate whether the remaining salary is greater than or equal to 500. \n", + "Utilice una variable booleana para indicar si el salario restante es mayor o igual a 500. \n", "\n", - "Finally, you will use string formatting to print a message to the screen in the following format: \n", - "\"*name*, who is *age* years old, and lives in *address* has *remaining_salary* dollars left from her salary after expenses. It is *is_salary_good* that she has more than $500 left.\", using the mentioned variables.\n", + "Finalmente, utilizará el formato de cadena para imprimir un mensaje en la pantalla en el siguiente formato: \n", + "\"*nombre*, que tiene *edad* años y vive en *dirección*, le sobran *salario_restante* de su salario después de gastos. Es *salario_bueno* que le sobran más de $500.\", utilizando las variables nombradas.\n", "\n", - "*Hint:* \n", - "- *You can use the input() function to ask the user to enter their information. Beware that input() function returns a String.*\n", - "- *You can round the remaining salary to one decimal using the round() function.*\n", - "- *Use data type conversion functions. Recommended external resources: [Data type conversion](https://www.geeksforgeeks.org/type-conversion-in-python/)*" + "*Pista:* \n", + "- *Puedes usar la función input() para pedirle al usuario que ingrese su información. Tenga en cuenta que la función input() devuelve una cadena.*\n", + "- *Puedes redondear el salario restante a un decimal usando la función round().*\n", + "- *Utilizar funciones de conversión de tipos de datos. Recursos externos recomendados: [Conversión de tipo de datos](https://www.geeksforgeeks.org/type-conversion-in-python/)*" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "crear un diccionario\n", + "colocar las valores a las claves del diccionario\n", + "ese nuevo diccionario preguntar si la resta de salario y gastos son mayor e igual a 500\n", + "si es true print\n" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 20, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "diccionario = {}\n", + "\n", + "diccionario['nombre'] = input('ingresa tu nombre')\n", + "diccionario['edad'] = int(input('ingresa tu edad'))\n", + "diccionario['direccion'] = (input('ingresa tu direccion'))\n", + "diccionario['salario'] = float(input('ingresa tu salario'))\n", + "diccionario['gasto'] = float(input('ingresa tus gasto mensual'))" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "500" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "salario_restante = round(diccionario.get('salario') - diccionario.get('gasto'))\n", + "salario_restante" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "if salario_restante >= (500):\n", + " salario_bueno = True \n", + "else:\n", + " salario_bueno = False\n", + "salario_bueno" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "juca, que tiene 34 años y vive en madrid, le sobran 500 de su salario despues de gastos. Es True que le sobran mas de $500.\n" + ] + } + ], + "source": [ + "print(f\"{diccionario['nombre']}, que tiene {diccionario['edad']} años y vive en {diccionario['direccion']}, le sobran {salario_restante} de su salario despues de gastos. Es {salario_bueno} que le sobran mas de $500.\")" ] }, { @@ -68,24 +146,23 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Write code that takes text from the variable `poem`, removes the punctuation and leaves everything in lowercase. \n", + "Escribe código que tome texto de la variable `poema`, elimine la puntuación y deje todo en minúsculas. \n", "\n", - "Concatenate the resulting string with the string \"python is awesome!\" and store the result in a new variable. \n", + "Concatene la cadena resultante con la cadena \"¡python es increíble!\" y almacenar el resultado en una nueva variable. \n", "\n", - "Print the length of the new string.\n", + "Imprime la longitud de la nueva cadena.\n", "\n", - "Split the string into a list of strings using the space delimiter, save it in a variable `poem_list` and print it. \n", + "Divida la cadena en una lista de cadenas usando el delimitador de espacio, guárdela en una variable `poem_list` e imprímala.\n", "\n", "*Hint:*\n", - "\n", - "- *You can use the len() function to get the length of a string.*\n", - "- *Search string methods to accomplish the other steps. Recommended External Resources: [Python String Methods](https://www.w3schools.com/python/python_ref_string.asp)*\n", - "- *Use method chaining to simplify your code. If you are not sure what it is, read this tutorial before: https://pyneng.readthedocs.io/en/latest/book/04_data_structures/method_chaining.html*\n" + "- *Puedes usar la función len() para obtener la longitud de una cadena.*\n", + "- *Buscar métodos de cadena para realizar los demás pasos. Recursos externos recomendados: [Métodos de cadenas de Python](https://www.w3schools.com/python/python_ref_string.asp)*\n", + "- *Utilice el encadenamiento de métodos para simplificar su código. Si no estás seguro de qué es, lee este tutorial antes: https://pyneng.readthedocs.io/en/latest/book/04_data_structures/method_chaining.html*\n" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -102,17 +179,66 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 41, "metadata": {}, "outputs": [], "source": [ - "# Your code here\n" + "import string\n", + "poem_low = poem.lower()\n", + "poema_limpio = poem_low.translate(str.maketrans('','', string.punctuation + '’'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "261\n" + ] + } + ], + "source": [ + "texto = \"¡python es increíble!\"\n", + "nuevo_texto = poema_limpio + \" \" + texto\n", + "print(len(nuevo_texto))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'ive', 'tasted', 'of', 'desire', 'i', 'hold', 'with', 'those', 'who', 'favor', 'fire', 'but', 'if', 'it', 'had', 'to', 'perish', 'twice', 'i', 'think', 'i', 'know', 'enough', 'of', 'hate', 'to', 'say', 'that', 'for', 'destruction', 'ice', 'is', 'also', 'great', 'and', 'would', 'suffice', '¡python', 'es', 'increíble!']\n" + ] + }, + { + "data": { + "text/plain": [ + "54" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "poem_list = nuevo_texto.split()\n", + "print(poem_list)" ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "base", "language": "python", "name": "python3" }, @@ -126,7 +252,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.13" + "version": "3.14.6" } }, "nbformat": 4, From 9b6c2e6068d4ac49945d725d62a76675e154a008 Mon Sep 17 00:00:00 2001 From: Juan Carlos Del Mar Lostanau <147656412+Juancarlosdelmarlostanau@users.noreply.github.com> Date: Sat, 19 Sep 2026 14:41:00 +0200 Subject: [PATCH 2/2] Update cfu-data-types.ipynb MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit solución 2 --- cfu-data-types.ipynb | 73 +++++++++++++++----------------------------- 1 file changed, 24 insertions(+), 49 deletions(-) diff --git a/cfu-data-types.ipynb b/cfu-data-types.ipynb index bf518bb..1b28a02 100644 --- a/cfu-data-types.ipynb +++ b/cfu-data-types.ipynb @@ -59,7 +59,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -74,59 +74,44 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "500" + "600.6" ] }, - "execution_count": 21, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "salario_restante = round(diccionario.get('salario') - diccionario.get('gasto'))\n", + "salario_restante = round(diccionario.get('salario') - diccionario.get('gasto'), 1)\n", "salario_restante" ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 6, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "True" - ] - }, - "execution_count": 22, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ - "if salario_restante >= (500):\n", - " salario_bueno = True \n", - "else:\n", - " salario_bueno = False\n", - "salario_bueno" + "salario_bueno = salario_restante >= 500" ] }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "juca, que tiene 34 años y vive en madrid, le sobran 500 de su salario despues de gastos. Es True que le sobran mas de $500.\n" + "juca, que tiene 34 años y vive en madrid, le sobran 600.6 de su salario despues de gastos. Es True que le sobran mas de $500.\n" ] } ], @@ -146,23 +131,23 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Escribe código que tome texto de la variable `poema`, elimine la puntuación y deje todo en minúsculas. \n", + "Write code that takes text from the `poem` variable, removes punctuation, and leaves everything lowercase. \n", "\n", - "Concatene la cadena resultante con la cadena \"¡python es increíble!\" y almacenar el resultado en una nueva variable. \n", + "Concatenate the resulting string with the string \"python is awesome!\" and store the result in a new variable. \n", "\n", - "Imprime la longitud de la nueva cadena.\n", + "Prints the length of the new string.\n", "\n", - "Divida la cadena en una lista de cadenas usando el delimitador de espacio, guárdela en una variable `poem_list` e imprímala.\n", + "Split the string into a list of strings using the space delimiter, store it in a variable `poem_list` and print it.\n", "\n", "*Hint:*\n", - "- *Puedes usar la función len() para obtener la longitud de una cadena.*\n", - "- *Buscar métodos de cadena para realizar los demás pasos. Recursos externos recomendados: [Métodos de cadenas de Python](https://www.w3schools.com/python/python_ref_string.asp)*\n", - "- *Utilice el encadenamiento de métodos para simplificar su código. Si no estás seguro de qué es, lee este tutorial antes: https://pyneng.readthedocs.io/en/latest/book/04_data_structures/method_chaining.html*\n" + "- *You can use the len() function to get the length of a string.*\n", + "- *Find string methods to perform the other steps. Recommended external resources: [Python String Methods](https://www.w3schools.com/python/python_ref_string.asp)*\n", + "- *Use method chaining to simplify your code. If you are not sure what it is, read this tutorial first: https://pyneng.readthedocs.io/en/latest/book/04_data_structures/method_chaining.html*" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 8, "metadata": {}, "outputs": [], "source": [ @@ -179,7 +164,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 9, "metadata": {}, "outputs": [], "source": [ @@ -190,44 +175,34 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "261\n" + "258\n" ] } ], "source": [ - "texto = \"¡python es increíble!\"\n", + "texto = \"python is awesome!\"\n", "nuevo_texto = poema_limpio + \" \" + texto\n", "print(len(nuevo_texto))" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'ive', 'tasted', 'of', 'desire', 'i', 'hold', 'with', 'those', 'who', 'favor', 'fire', 'but', 'if', 'it', 'had', 'to', 'perish', 'twice', 'i', 'think', 'i', 'know', 'enough', 'of', 'hate', 'to', 'say', 'that', 'for', 'destruction', 'ice', 'is', 'also', 'great', 'and', 'would', 'suffice', '¡python', 'es', 'increíble!']\n" + "['some', 'say', 'the', 'world', 'will', 'end', 'in', 'fire', 'some', 'say', 'in', 'ice', 'from', 'what', 'ive', 'tasted', 'of', 'desire', 'i', 'hold', 'with', 'those', 'who', 'favor', 'fire', 'but', 'if', 'it', 'had', 'to', 'perish', 'twice', 'i', 'think', 'i', 'know', 'enough', 'of', 'hate', 'to', 'say', 'that', 'for', 'destruction', 'ice', 'is', 'also', 'great', 'and', 'would', 'suffice', 'python', 'is', 'awesome!']\n" ] - }, - { - "data": { - "text/plain": [ - "54" - ] - }, - "execution_count": 49, - "metadata": {}, - "output_type": "execute_result" } ], "source": [