diff --git a/exercises/06-lambda-functions/README.es.md b/exercises/06-lambda-functions/README.es.md index a12cdf6..40dcd34 100644 --- a/exercises/06-lambda-functions/README.es.md +++ b/exercises/06-lambda-functions/README.es.md @@ -1,39 +1,41 @@ -# `06` Funciones Lambda en Python +# `06` Lambda Functions in Python Una **función lambda** es una función con solo una línea de código y sin nombre. -Es un tipo de función muy especial en el mundo Python porque puedes usarla como una 'pequeña utilidad' para una programación muy ágil: +Es un tipo de función muy especial en el mundo Python porque puedes usarla como una pequeña utilidad para una programación muy ágil: ```python -# declarando una función normal para una multiplicación +# Declarando una función normal para una multiplicación def multiply(p1, p2): return p1 * p2 -# declarándola en una línea como una función lambda +# Declarándola en una línea como una función lambda multiply = lambda p1,p2: p1 * p2 ``` -1. Las **funciones lambda** tiene que ser siempre muy pequeñas. +### 👉 Caracteristicas: -2. Las **funciones lambda** pueden tener únicamente una línea. ++ Las **funciones lambda** tienen que ser siempre muy pequeñas. -3. Las **funciones lambda** no necesitan un `return`, se asume que lo que haya en esa línea devolverá un valor. ++ Las **funciones lambda** pueden tener únicamente una línea. -4. Las **funciones lambda** pueden almacenarse en variables o ser pasadas como parámetro a otra función. ++ Las **funciones lambda** no necesitan un `return`, se asume que lo que haya en esa línea devolverá un valor. + ++ Las **funciones lambda** pueden almacenarse en variables o ser pasadas como parámetro a otra función. ## 📝 Instrucciones: 1. Crea una variable llamada `is_odd`. -2. Asígnale una función lambda que devuelva `True` o `False` dependiendo de si un número dado es impar o no. +2. Asígnale una función **lambda** que devuelva `True` o `False` dependiendo de si un número dado es impar o no. ## 💡 Pista: + Así es como declararías una función normal: ```python -# Esta función retorna `True` si el número es impar +# Esta función retorna "True" si el número es impar def is_odd(num): return (num % 2) != 0 ``` diff --git a/exercises/06-lambda-functions/README.md b/exercises/06-lambda-functions/README.md index dd38458..771ef04 100755 --- a/exercises/06-lambda-functions/README.md +++ b/exercises/06-lambda-functions/README.md @@ -3,29 +3,30 @@ tutorial: "https://www.youtube.com/watch?v=HACQ9uerCuE" --- -# `06` Lambda functions in Python +# `06` Lambda Functions in Python A **lambda function** is a function with just one line of code and no name. -It is a very special type of funcion in the world of python because you can use it as a small utility for very agile coding: +It is a very special type of function in the world of Python because you can use it as a small utility for very agile coding: ```python -# declaring a normal funcion for multiplication +# Declaring a normal function for multiplication def multiply(p1, p2): return p1 * p2 -# declaring it now like a one line lambda +# Declaring it now like a one line lambda function multiply = lambda p1,p2: p1 * p2 ``` -:point_uo:Facts: -+ **Lambda fuctions** have to be always very small. +### 👉 Facts: -+ **Lambda function** can only have one line. ++ **Lambda functions** have to always be very small. -+ **Lambda function** doesn't need a `return` statement (it is assumed that it will return whatever is on that one line). ++ **Lambda functions** can only have one line. -+ **Lambda functions** can be stored in variables or passed as parameters to another function ++ **Lambda functions** don't need a `return` statement (it is assumed that it will return whatever is on that one line). + ++ **Lambda functions** can be stored in variables or passed as parameters to another function. ## 📝 Instructions: @@ -33,12 +34,12 @@ multiply = lambda p1,p2: p1 * p2 2. Assign a **lambda function** to it that returns `True` or `False` if a given number is odd. -## 💡Hint +## 💡 Hint + Here is how you would declare it like a normal function: ```py -# this function return True if a number is odd. +# This function returns True if a number is odd def is_odd(num): return num % 2 != 0 ``` diff --git a/exercises/06-lambda-functions/app.py b/exercises/06-lambda-functions/app.py index e59626e..b4ac556 100755 --- a/exercises/06-lambda-functions/app.py +++ b/exercises/06-lambda-functions/app.py @@ -1,2 +1,2 @@ -# your function here +# Your function here diff --git a/exercises/06-lambda-functions/solution.hide.py b/exercises/06-lambda-functions/solution.hide.py new file mode 100644 index 0000000..f134619 --- /dev/null +++ b/exercises/06-lambda-functions/solution.hide.py @@ -0,0 +1,3 @@ +# Your function here + +is_odd = lambda num: num % 2 != 0 diff --git a/exercises/06-lambda-functions/tests.py b/exercises/06-lambda-functions/tests.py index bce6293..aa3054a 100755 --- a/exercises/06-lambda-functions/tests.py +++ b/exercises/06-lambda-functions/tests.py @@ -1,6 +1,6 @@ import io, sys, pytest, os, re, mock -@pytest.mark.it("Declare a function 'is_odd' as lambda") +@pytest.mark.it("Declare a function called 'is_odd' as lambda") def test_declare_variable(): path = os.path.dirname(os.path.abspath(__file__))+'/app.py' with open(path, 'r') as content_file: @@ -13,7 +13,7 @@ def test_for_callable(capsys): import app as app assert callable(app.is_odd) -@pytest.mark.it('The function is_odd must receive one number and return true if is odd or false otherwise') +@pytest.mark.it('The function is_odd must receive one number and return True if the number is odd or False otherwise') def test_for_integer(capsys): import app as app assert app.is_odd(3) == True @@ -21,4 +21,4 @@ def test_for_integer(capsys): @pytest.mark.it('We tested the function with 2 and the result was not False') def test_for_integer2(capsys): import app as app - assert app.is_odd(2) == False \ No newline at end of file + assert app.is_odd(2) == False diff --git a/exercises/07-lambda-function-two/README.es.md b/exercises/07-lambda-function-two/README.es.md index e9f470b..c85e631 100644 --- a/exercises/07-lambda-function-two/README.es.md +++ b/exercises/07-lambda-function-two/README.es.md @@ -1,13 +1,12 @@ -# `07` Funciones Lambda +# `07` Lambda Functions - -**:point_up: Recuerda:** +### ☝ Recuerda: Las funciones Lambda permiten una sintaxis corta para escribir expresiones de funciones. ```python -multy = lambda x, y: x * y -print(multy(2,2)) +multiply = lambda x, y: x * y +print(multiply(2,2)) ``` ## 📝 Instrucciones: @@ -18,4 +17,4 @@ print(multy(2,2)) ## 💡 Pista: -+ Busca en Google "remove last letter form string python" (puedes usar los corchetes). ++ Busca en Google "como eliminar el último caracter de un string python" (puedes usar los corchetes). diff --git a/exercises/07-lambda-function-two/README.md b/exercises/07-lambda-function-two/README.md index 69fa2ce..8796c77 100755 --- a/exercises/07-lambda-function-two/README.md +++ b/exercises/07-lambda-function-two/README.md @@ -2,23 +2,23 @@ tutorial: "https://www.youtube.com/watch?v=1HwmTkQPeMo" --- -# `07` Lambda functions +# `07` Lambda Functions -**:point_up: Remember:** +### ☝ Remember: -Lambda functions allows a short syntax for writing function expressions. +Lambda functions allow a short syntax for writing function expressions. ```python -multy = lambda x, y: x * y -print(multy(2,2)) +multiply = lambda x, y: x * y +print(multiply(2,2)) ``` ## 📝 Instructions: -1. Create a lambda function called `rapid` it will take one string parameter. +1. Create a lambda function called `rapid`, which will take one string parameter. 2. Return the same string with the last letter removed. -## 💡 Hint +## 💡 Hint: -+ Google how to "remove last letter form string python" (you can use the square brackets). ++ Google "how to remove last letter from string python" (you can use the square brackets). diff --git a/exercises/07-lambda-function-two/app.py b/exercises/07-lambda-function-two/app.py index fca265d..a156102 100755 --- a/exercises/07-lambda-function-two/app.py +++ b/exercises/07-lambda-function-two/app.py @@ -1,5 +1,5 @@ -# From this line above, plese do not change code below -print(rapid("bob")) #should print bo \ No newline at end of file +# Your code above, please do not change code below +print(rapid("bob")) # Should print "bo" diff --git a/exercises/07-lambda-function-two/solution.hide.py b/exercises/07-lambda-function-two/solution.hide.py index 963f084..ecfc065 100644 --- a/exercises/07-lambda-function-two/solution.hide.py +++ b/exercises/07-lambda-function-two/solution.hide.py @@ -1,5 +1,4 @@ rapid = lambda myStr: myStr[:-1] - -# From this line above, plese do not change code below -print(rapid("bob")) #should print bo \ No newline at end of file +# Your code above, please do not change code below +print(rapid("bob")) # Should print "bo" diff --git a/exercises/07-lambda-function-two/tests.py b/exercises/07-lambda-function-two/tests.py index 39787f2..7b6a474 100755 --- a/exercises/07-lambda-function-two/tests.py +++ b/exercises/07-lambda-function-two/tests.py @@ -1,6 +1,6 @@ import io, sys, pytest, os, re, mock -@pytest.mark.it("Declare a function 'rapid' as lambda") +@pytest.mark.it("Declare a function called 'rapid' as lambda") def test_declare_variable(): path = os.path.dirname(os.path.abspath(__file__))+'/app.py' with open(path, 'r') as content_file: @@ -12,7 +12,7 @@ def test_declare_variable(): def test_for_callable(capsys): from app import rapid -@pytest.mark.it('The function rapid must receive one string and return the same but without the last letter (make sure it\'s lowecase)') +@pytest.mark.it('The function rapid must receive one string and return the same string without the last character') def test_for_integer(capsys): from app import rapid assert rapid("maria") == "mari" diff --git a/exercises/08-Function-that-returns/README.es.md b/exercises/08-Function-that-returns/README.es.md index cd6fd25..add2e88 100644 --- a/exercises/08-Function-that-returns/README.es.md +++ b/exercises/08-Function-that-returns/README.es.md @@ -1,8 +1,10 @@ -# `08` Funciones que devuelven +# `08` Functions that return Es una muy buena práctica que las funciones devuelvan algo, incluso si es `None`. -Si tus funciones devuelven algo, puedes crear algoritmos que usen muchas funciones al mismo tiempo. Por ejemplo, en este caso en particular tenemos dos funciones disponibles: +Si tus funciones devuelven algo, puedes crear algoritmos que usen muchas funciones al mismo tiempo. + +Por ejemplo, en este caso en particular tenemos dos funciones disponibles: + `dollar_to_euro`: que calcula el valor en euros de un valor dado en dólares. @@ -12,12 +14,12 @@ Si tus funciones devuelven algo, puedes crear algoritmos que usen muchas funcion 1. Utilizando las dos funciones disponibles, imprime en la consola el valor de **137** dólares en yenes. -## 💡 Pista: +## 💡 Pistas: -Trabajando al revés: +Trabajando desde el final: - Nuestro valor esperado está en yenes. - Nuestra función disponible `euro_to_yen` proporcionará eso. -- Para llegar al euro utilizaremos la función disponible `dollar_to_euro`. \ No newline at end of file +- Para llegar al euro utilizaremos la función disponible `dollar_to_euro`. diff --git a/exercises/08-Function-that-returns/README.md b/exercises/08-Function-that-returns/README.md index cd56ca6..1f4a6d7 100755 --- a/exercises/08-Function-that-returns/README.md +++ b/exercises/08-Function-that-returns/README.md @@ -8,18 +8,17 @@ It is very good practice that all functions return something, even if it is `Non With what your function returns, you can create algorithms that use multiple functions at the same time. -For example, in this particular case we have two functions available: +For example, in this particular case, we have two functions available: + `dollar_to_euro`: that calculates the value in euros of a given value in dollars. + `euro_to_yen`: calculates the value in yen of a given value in euros. - ## 📝 Instructions: 1. Using the two functions available, print on the console the value of **137** dollars in yen. -## 💡 Hint +## 💡 Hints: Working backwards: @@ -27,4 +26,4 @@ Working backwards: - Our available function `euro_to_yen` will provide that. -- To get to euro we will use the available function `dollar_to_euro`. +- To get the euros, we will use the available function `dollar_to_euro`. diff --git a/exercises/08-Function-that-returns/app.py b/exercises/08-Function-that-returns/app.py index 44ab611..fc81947 100755 --- a/exercises/08-Function-that-returns/app.py +++ b/exercises/08-Function-that-returns/app.py @@ -1,7 +1,7 @@ def dollar_to_euro(dollar_value): - return dollar_value * 0.89 + return dollar_value * 0.91 def euro_to_yen(euro_value): - return euro_value * 124.15 + return euro_value * 161.70 -####### ↓ YOUR CODE BELOW ↓ ####### \ No newline at end of file +####### ↓ YOUR CODE BELOW ↓ ####### diff --git a/exercises/08-Function-that-returns/solution.hide.py b/exercises/08-Function-that-returns/solution.hide.py new file mode 100644 index 0000000..82ee742 --- /dev/null +++ b/exercises/08-Function-that-returns/solution.hide.py @@ -0,0 +1,12 @@ +def dollar_to_euro(dollar_value): + return dollar_value * 0.91 + +def euro_to_yen(euro_value): + return euro_value * 161.70 + +####### ↓ YOUR CODE BELOW ↓ ####### + +euros = dollar_to_euro(137) +yen = euro_to_yen(euros) + +print(yen) diff --git a/exercises/08-Function-that-returns/test.py b/exercises/08-Function-that-returns/test.py index 812e1c7..f45e234 100755 --- a/exercises/08-Function-that-returns/test.py +++ b/exercises/08-Function-that-returns/test.py @@ -1,6 +1,6 @@ import io, sys, pytest, os, re, mock -@pytest.mark.it("Call the function dollar_to_euro passing the 137 dollars to get the amount in Euro") +@pytest.mark.it("Call the function dollar_to_euro passing 137 dollars to get the amount in Euros") def test_declare_variable(): path = os.path.dirname(os.path.abspath(__file__))+'/app.py' with open(path, 'r') as content_file: @@ -9,7 +9,7 @@ def test_declare_variable(): assert bool(regex.search(content)) == True -@pytest.mark.it("Call the function euro_to_yen passing the Euro converted amount to get the amount in Yen") +@pytest.mark.it("Call the function euro_to_yen passing the Euros converted amount to get the amount in Yen") def test_euro_to_yen(): path = os.path.dirname(os.path.abspath(__file__))+'/app.py' with open(path, 'r') as content_file: @@ -22,4 +22,4 @@ def test_euro_to_yen(): def test_for_file_output(capsys): import app captured = capsys.readouterr() - assert "15137.609500000002\n" == captured.out \ No newline at end of file + assert "20159.139\n" == captured.out diff --git a/exercises/09-Function-parameters/README.es.md b/exercises/09-Function-parameters/README.es.md index 6500706..ca03d09 100644 --- a/exercises/09-Function-parameters/README.es.md +++ b/exercises/09-Function-parameters/README.es.md @@ -1,4 +1,4 @@ -# `09` Parámetros de funciones +# `09` Function parameters Puedes especificar tantos parámetros como desees en una función. @@ -8,12 +8,14 @@ Los nombres de los parámetros no importan, pero debe ser **lo más explícito p ## 📝 Instrucciones: -+ Escribe la función `render_person` requerida para imprimir un string como el siguiente: +1. Escribe la función `render_person` requerida para imprimir un string como el siguiente: -```py +```text Bob is a 23 years old male born in 05/22/1983 with green eyes ``` -## 💡 Pista +## 💡 Pistas: -- Tienes que hacer una concatenación de string y devolver ese string. ++ Tienes que hacer una concatenación de string y devolver ese string. + ++ También, puedes buscar en Google "como insertar variables en un string python". diff --git a/exercises/09-Function-parameters/README.md b/exercises/09-Function-parameters/README.md index 1301c1a..d8a4321 100755 --- a/exercises/09-Function-parameters/README.md +++ b/exercises/09-Function-parameters/README.md @@ -6,18 +6,20 @@ tutorial: "https://www.youtube.com/watch?v=uaiDxW4LJNA" You can specify as many parameters as you want in a function. -As a developer you are going to find functions with even 6 or 7 parameters all the time. +As a developer, you are going to find functions with even 6 or 7 parameters all the time. The names of the parameters don't matter, but you have to be **as explicit as you can** because these names will give clues to the other developers (or yourself in the future) about what is each parameter about. ## 📝 Instructions: -1. Please write the `render_person` function required to print a a string like the following: +1. Please write the `render_person` function required to print a string like the following: -```py +```text Bob is a 23 years old male born in 05/22/1983 with green eyes ``` -## 💡 Hint +## 💡 Hints: + You have to do some string concatenation and return that string. + ++ Also, you can Google "how to insert variables into a string python". diff --git a/exercises/09-Function-parameters/solution.hide.py b/exercises/09-Function-parameters/solution.hide.py index 71e6d5f..1b50585 100644 --- a/exercises/09-Function-parameters/solution.hide.py +++ b/exercises/09-Function-parameters/solution.hide.py @@ -1,7 +1,7 @@ # Your code goes here: -def render_person(name, birthdate, eye_color, age, sex): - return name +" is a "+ str(age) +" years old " + sex +" born in " + birthdate + " with "+eye_color +" eyes" +def render_person(name, birth_date, eye_color, age, gender): + return name + " is a " + str(age) + " years old " + gender + " born in " + birth_date + " with " + eye_color + " eyes" # Do not edit below this line -print(render_person('Bob', '05/22/1983', 'green', 23, 'male')) \ No newline at end of file +print(render_person('Bob', '05/22/1983', 'green', 23, 'male')) diff --git a/exercises/10-Array-Methods/README.es.md b/exercises/10-Array-Methods/README.es.md index 938c2ad..1c2810b 100644 --- a/exercises/10-Array-Methods/README.es.md +++ b/exercises/10-Array-Methods/README.es.md @@ -1,13 +1,13 @@ -# `10` Métodos de listas +# `10` List Methods ## 📝 Instrucciones: 1. Escribe una función llamada `sort_names` que dada una lista de nombres, los devuelva en orden alfabético. -## 💡 Pista: +## 💡 Pistas: -- Cada lista viene con funciones predeterminadas que permiten ordenarla ¡úsalas dentro de tu función! +- Cada lista viene con funciones predeterminadas que permiten ordenarla, ¡úsalas dentro de tu función! -+ ¿Atrapado en el orden? Lee esta página sobre cómo ordenar listas: ++ ¿Atascado? Lee esta página sobre cómo ordenar listas: -https://www.freecodecamp.org/espanol/news/python-ordenar-lista-con-sort-ascendente-y-descendente-explicado-con-ejemplos/ \ No newline at end of file +https://www.freecodecamp.org/espanol/news/python-ordenar-lista-con-sort-ascendente-y-descendente-explicado-con-ejemplos/ diff --git a/exercises/10-Array-Methods/README.md b/exercises/10-Array-Methods/README.md index 26cc991..69316e3 100755 --- a/exercises/10-Array-Methods/README.md +++ b/exercises/10-Array-Methods/README.md @@ -2,17 +2,16 @@ tutorial: "https://www.youtube.com/watch?v=jBXve_vh7dU" --- - # `10` List Methods ## 📝 Instructions: 1. Write a function called `sort_names` that, given a list of names, returns them in alphabetical order. -## 💡 Hint +## 💡 Hints: -+ Every list comes with default functions that allows sorting- use it inside your function! ++ Every list comes with default functions that allow sorting - use them inside your function! -+ Stuck on sorting? Read W3 Schools page on sorting lists: ++ Stuck on sorting? Read the W3 Schools page on sorting lists: -https://www.w3schools.com/python/ref_list_sort.asp +https://www.w3schools.com/python/ref_func_sorted.asp diff --git a/exercises/10-Array-Methods/app.py b/exercises/10-Array-Methods/app.py index c88bc18..9d60f6b 100755 --- a/exercises/10-Array-Methods/app.py +++ b/exercises/10-Array-Methods/app.py @@ -1,4 +1,6 @@ names = ['John', 'Kenny', 'Tom', 'Bob', 'Dilan'] + ## CREATE YOUR FUNCTION HERE + print(sort_names(names)) diff --git a/exercises/10-Array-Methods/solution.hide.py b/exercises/10-Array-Methods/solution.hide.py index f63fbd8..37e6930 100644 --- a/exercises/10-Array-Methods/solution.hide.py +++ b/exercises/10-Array-Methods/solution.hide.py @@ -1,2 +1,8 @@ +names = ['John', 'Kenny', 'Tom', 'Bob', 'Dilan'] + +## CREATE YOUR FUNCTION HERE def sort_names (arr): return sorted(arr) + + +print(sort_names(names)) diff --git a/exercises/10-Array-Methods/tests.py b/exercises/10-Array-Methods/tests.py index 76a6c4d..5cce1e5 100755 --- a/exercises/10-Array-Methods/tests.py +++ b/exercises/10-Array-Methods/tests.py @@ -1,6 +1,6 @@ import io, sys, pytest, os, re, mock -@pytest.mark.it("Declare the function sort_names") +@pytest.mark.it("Declare the function 'sort_names'") def test_declare_variable(): path = os.path.dirname(os.path.abspath(__file__))+'/app.py' with open(path, 'r') as content_file: @@ -13,7 +13,7 @@ def test_declare_variable(): def test_for_functon_existence(capsys, app): assert callable(app.sort_names) -@pytest.mark.it('The function sort_names must accept 1 parameter and return a sorted one') +@pytest.mark.it('The function sort_names must accept a list and return a sorted one') def test_for_file_output(capsys): import app captured = capsys.readouterr()