diff --git a/exercises/05-User-Inputed-Values/README.es.md b/exercises/05-User-Inputed-Values/README.es.md index ede34ffc..ecbbf140 100644 --- a/exercises/05-User-Inputed-Values/README.es.md +++ b/exercises/05-User-Inputed-Values/README.es.md @@ -2,14 +2,14 @@ Otra cosa genial de las variables es que no necesitas saber su valor para poder trabajar con ellas. -Por ejemplo, justo ahora la aplicación está preguntando la edad del usuario, y luego la imprime en la cónsola. +Por ejemplo, justo ahora la aplicación está preguntando la edad del usuario, y luego la imprime en la consola. ## 📝 Instrucciones: 1. Por favor, añade 10 años al valor de la variable `age`. -## 💡 Pista: +## 💡 Pistas: + Puedes buscar en Google "Como sumarle una cantidad a una variable de Python". -+ Recuerda que el contenido de la variable está siendo definido con lo que sea que el usuario coloque. \ No newline at end of file ++ Recuerda que el contenido de la variable está siendo definido con lo que sea que el usuario coloque. diff --git a/exercises/05-User-Inputed-Values/README.md b/exercises/05-User-Inputed-Values/README.md index 49cb46b8..364fc56a 100644 --- a/exercises/05-User-Inputed-Values/README.md +++ b/exercises/05-User-Inputed-Values/README.md @@ -12,8 +12,8 @@ For example, the application right now is prompting the user for its age, and th 1. Please add 10 years to the value of the age variable. -## 💡Hint +## 💡 Hints: -+ You can Google "how to add a number to a python variable". ++ You can Google "how to add a number to a Python variable". -+ Remember that the content of the variable its being previously filled with whatever the user inputs. \ No newline at end of file ++ Remember that the content of the variable is being previously filled with whatever the user inputs. diff --git a/exercises/05-User-Inputed-Values/test.py b/exercises/05-User-Inputed-Values/test.py index 2a660472..7409b8f8 100644 --- a/exercises/05-User-Inputed-Values/test.py +++ b/exercises/05-User-Inputed-Values/test.py @@ -9,7 +9,7 @@ def test_for_file_output(capsys): regex = re.compile(pattern) assert bool(regex.search(content)) == True -@pytest.mark.it("We tried with age 50 and it was supposed to return 60") +@pytest.mark.it("Testing with age 50 and it is supposed to return 60") @mock.patch('builtins.input', lambda x: 50) def test_plus_ten(stdin): # f = open(os.path.dirname(os.path.abspath(__file__))+'/app.py') diff --git a/exercises/06-String-Concatenation/README.es.md b/exercises/06-String-Concatenation/README.es.md index 382ed1b7..56b080d2 100644 --- a/exercises/06-String-Concatenation/README.es.md +++ b/exercises/06-String-Concatenation/README.es.md @@ -7,10 +7,9 @@ Puedes pensar en este proceso como conectar dos o más vagones de tren. Si cada En Python, puedes concatenar o unir dos o más strings usando el operador `+`. Así es como funciona: ```py - one = 'a' two = 'b' -print(one + two) # esto imprimirá 'ab' en la consola. +print(one + two) # Esto imprimirá 'ab' en la consola. ``` Aquí, las variables `one` y `two` contienen los strings individuales `'a'` y `'b'`, respectivamente. Cuando usas el operador `+` entre ellos, actúa como un pegamento, uniendo los strings de extremo a extremo. En este caso, une `'a'` y `'b'`, dando como resultado el string concatenado `'ab'`, que se imprime en la consola. @@ -20,4 +19,4 @@ Aquí, las variables `one` y `two` contienen los strings individuales `'a'` y `' ## 💡 Pista: -+ Si necesitas más explicación sobre como la **concatenación** funciona en Python, puedes ver este clip: https://www.youtube.com/watch?v=T1nyPuAhd1U&ab_channel=ProgramaResuelto (`ctrl + click` en el enlance para abrir el video) ++ Si necesitas más explicación sobre como funciona la **concatenación** en Python, puedes ver este clip: https://www.youtube.com/watch?v=T1nyPuAhd1U&ab_channel=ProgramaResuelto (`ctrl + click` en el enlace para abrir el video) diff --git a/exercises/06-String-Concatenation/README.md b/exercises/06-String-Concatenation/README.md index 7bf0f55a..541ec12f 100644 --- a/exercises/06-String-Concatenation/README.md +++ b/exercises/06-String-Concatenation/README.md @@ -11,16 +11,15 @@ You can think of this process as similar to connecting two or more train cars. I In Python, you can concatenate, or join together, two or more strings using the `+` operator. This is how it works: ```py - one = 'a' two = 'b' -print(one + two) # this will print 'ab' on the console. +print(one + two) # This will print 'ab' on the console. ``` Here, the variables `one` and `two` hold the individual strings `'a'` and `'b'`. When you use the `+` operator between them, it acts like a glue, sticking the strings together end-to-end. In this case, it joins `'a'` and `'b'`, resulting in the concatenated string `'ab'`, which gets printed to the console. ## 📝 Instructions: -1. Set the values for `my_var1` and `my_var2` so that when concatenated, the code prints `Hello World` in the console. +1. Set the values for `my_var1` and `my_var2` so that, when concatenated, the code prints `Hello World` in the console. ## 💡 Hint: -+ If you need further explanation on how string **concatenation** works in python, you can watch this clip: https://www.youtube.com/watch?v=28FUVmWU_fA&ab_channel=PortfolioCourses (`ctrl + click` on the link to open the video) ++ If you need further explanation on how string **concatenation** works in Python, you can watch this clip: https://www.youtube.com/watch?v=28FUVmWU_fA&ab_channel=PortfolioCourses (`ctrl + click` on the link to open the video) diff --git a/exercises/06-String-Concatenation/app.py b/exercises/06-String-Concatenation/app.py index 5eefe43b..97521fb2 100644 --- a/exercises/06-String-Concatenation/app.py +++ b/exercises/06-String-Concatenation/app.py @@ -1,6 +1,6 @@ # ✅ ↓ Set the values for my_var1 and my_var2 here ↓ ✅ -## Don't change below this line -the_new_string = my_var1+' '+my_var2 -print(the_new_string) \ No newline at end of file +## Don't change anything below this line +the_new_string = my_var1 + ' ' + my_var2 +print(the_new_string) diff --git a/exercises/06-String-Concatenation/solution.hide.py b/exercises/06-String-Concatenation/solution.hide.py index 45c6ee72..74f82acc 100644 --- a/exercises/06-String-Concatenation/solution.hide.py +++ b/exercises/06-String-Concatenation/solution.hide.py @@ -3,6 +3,6 @@ my_var1 = "Hello" my_var2 = "World" -## Don't change below this line -the_new_string = my_var1+' '+my_var2 -print(the_new_string) \ No newline at end of file +## Don't change anything below this line +the_new_string = my_var1 + ' ' + my_var2 +print(the_new_string) diff --git a/exercises/06-String-Concatenation/test.py b/exercises/06-String-Concatenation/test.py index 69fe26a8..a0d74abb 100644 --- a/exercises/06-String-Concatenation/test.py +++ b/exercises/06-String-Concatenation/test.py @@ -27,7 +27,7 @@ def test_my_var2_value(): from app import my_var2 assert my_var2.lower() == "world" -@pytest.mark.it("Variable my_var2 value should be 'World'") +@pytest.mark.it("Don't remove the_new_string variable") def test_the_new_string_exists(): import app try: @@ -38,4 +38,4 @@ def test_the_new_string_exists(): @pytest.mark.it('Print "Hello World" on the console') def test_for_file_output(): captured = buffer.getvalue() - assert "hello world\n" in captured.lower() #add \n because the console jumps the line on every print \ No newline at end of file + assert "hello world\n" in captured.lower() #add \n because the console jumps the line on every print diff --git a/exercises/07-Create-a-Basic-HTML/README.es.md b/exercises/07-Create-a-Basic-HTML/README.es.md index 682ad8c0..0abe48b4 100644 --- a/exercises/07-Create-a-Basic-HTML/README.es.md +++ b/exercises/07-Create-a-Basic-HTML/README.es.md @@ -4,19 +4,17 @@ Continuemos concatenando strings para generar un documento HTML básico... ## 📝 Instrucciones: -1. Crea una variable **html_document**. +1. Crea la variable `html_document`. -2. El código a la izquierda contiene 8 variables con diferentes valores de tipo *string*. Por favor, usa las variables concatenándolas entre ellas para establecer el valor de la variable **html_document** como nuevo string que tenga el contenido de un documento HTML típico (con las etiquetas HTML -en el orden correcto). +2. El código a la izquierda contiene 8 variables con diferentes valores de tipo *string*. Por favor, usa las variables concatenándolas entre ellas para establecer el valor de la variable `html_document` a la estructura típica de un documento HTML (con las etiquetas HTML en el orden correcto). -3. Luego, imprime el valor de **html_document** en la consola. +3. Luego, imprime el valor de `html_document` en la consola. ## 💡 Pista: + Resultado esperado: -```sh - +```html ``` diff --git a/exercises/07-Create-a-Basic-HTML/README.md b/exercises/07-Create-a-Basic-HTML/README.md index f6abf000..2c5d41f4 100644 --- a/exercises/07-Create-a-Basic-HTML/README.md +++ b/exercises/07-Create-a-Basic-HTML/README.md @@ -2,26 +2,24 @@ tutorial: "https://www.youtube.com/watch?v=j14V-eS8mRg" --- -# `07` Create a basic HTML +# `07` Create a Basic HTML Let's continue using string concatenation to generate HTML... ## 📝 Instructions: -1. Create a variable **html_document**. +1. Create the variable `html_document`. -2. The code on the left contains 8 variables with different string values, please use the variables concatenating them together to set the value of the variable **html_document** -a new string that has the content of a typical HTML document (with the HTML tags in the -right order). +2. The code on the left contains 8 variables with different string values, please use the variables concatenating them together to set the value of the variable `html_document` +to a new string that has the content of a typical HTML document (with the HTML tags in the right order). -3. Then, print the value of **html_document** on the console. +3. Then, print the value of `html_document` on the console. ## 💡 Hint: + Expected Result: -```sh - +```html ``` diff --git a/exercises/07-Create-a-Basic-HTML/solution.hide.py b/exercises/07-Create-a-Basic-HTML/solution.hide.py index 4e180299..cda52eee 100644 --- a/exercises/07-Create-a-Basic-HTML/solution.hide.py +++ b/exercises/07-Create-a-Basic-HTML/solution.hide.py @@ -11,5 +11,5 @@ # ✅ ↓ start coding below here ↓ ✅ -html_document = e+c+g+a+f+h+d+b -print(html_document) \ No newline at end of file +html_document = e + c + g + a + f + h + d + b +print(html_document) diff --git a/exercises/08.1-Your-First-If/README.es.md b/exercises/08.1-Your-First-If/README.es.md index 5fa04204..b7ea9ac6 100644 --- a/exercises/08.1-Your-First-If/README.es.md +++ b/exercises/08.1-Your-First-If/README.es.md @@ -4,15 +4,15 @@ La aplicación actual está preguntando cuánto dinero tiene el usuario. Una vez ## 📝 Instrucciones: -1. Si el usuario tiene más de $100, respondemos: "Give me your money!" (Dame tu dinero). +1. Si el usuario tiene más de $100, respondemos: "Give me your money!" (¡Dame tu dinero!). -2. Si el usuario tiene más de $50, respondemos: "Buy me some coffee you cheap!" (¡Comprame un café!). +2. Si el usuario tiene más de $50, respondemos: "Buy me some coffee, you cheap!" (¡Cómprame un café!). 3. Si el usuario tiene igual o menos de $50, respondemos: "You are a poor guy, go away!" (¡Eres pobre!). -## 💡 Pista: +## 💡 Pistas: -+ Usa un condicional `if/else` para verificar el valor de la variable `total`. ++ Usa un condicional `if...else` para verificar el valor de la variable `total`. + Puedes leer más al respecto [aquí](https://docs.python.org/3/tutorial/controlflow.html#if-statements). @@ -20,9 +20,9 @@ La aplicación actual está preguntando cuánto dinero tiene el usuario. Una vez | Operador | Descripción | Sintaxis | |----------|------------------------------------------------------------------------------|----------| - | > | Mayor que: Verdadero si el operando izquierdo es mayor que el derecho | x > y | - | < | Menor que: Verdadero si el operando izquierdo es menor que el derecho | x < y | - | == | Igual a: Verdadero si ambos operandos son iguales | x == y | - | != | No igual a – Verdadero si los operandos no son iguales | x != y | - | >= | Mayor o igual que: Verdadero si el operando izquierdo es mayor o igual | x >= y | - | <= | Menor o igual que: Verdadero si el operando izquierdo es menor o igual | x <= y | + | > | Mayor que: True si el operando izquierdo es mayor que el derecho | x > y | + | < | Menor que: True si el operando izquierdo es menor que el derecho | x < y | + | == | Igual a: True si ambos operandos son iguales | x == y | + | != | No igual a: True si los operandos no son iguales | x != y | + | >= | Mayor o igual que: True si el operando izquierdo es mayor o igual | x >= y | + | <= | Menor o igual que: True si el operando izquierdo es menor o igual | x <= y | diff --git a/exercises/08.1-Your-First-If/README.md b/exercises/08.1-Your-First-If/README.md index e1f1a58e..8f36b753 100644 --- a/exercises/08.1-Your-First-If/README.md +++ b/exercises/08.1-Your-First-If/README.md @@ -2,7 +2,7 @@ tutorial: "https://www.youtube.com/watch?v=x9wqa5WQZiM" --- -# `08.1` Your First if... +# `08.1` Your First If... The current application is asking how much money the user has. Once the user inputs the amount, we need to **print** one of the following answers: @@ -10,23 +10,23 @@ The current application is asking how much money the user has. Once the user inp 1. If the user has more than $100, we answer: "Give me your money!". -2. If the user has more than $50, we answer: "Buy me some coffee you cheap!". +2. If the user has more than $50, we answer: "Buy me some coffee, you cheap!". -3. If the user has less or equal than $50, we answer: "You are a poor guy, go away!". +3. If the user has less than or equal to $50, we answer: "You are a poor guy, go away!". -## 💡 Hint: +## 💡 Hints: -+ Use an If/else statement to check the value of the `total` variable. ++ Use an `if...else` statement to check the value of the `total` variable. + Further information [here](https://docs.python.org/3/tutorial/controlflow.html#if-statements). + Here's a quick reminder on relational operators: - | Operator | Description | Syntax | - |----------|--------------------------------------------------------------------|-----------| - | > | Greater than: True if the left operand is greater than the right | x > y | - | < | Less than: True if the left operand is less than the right | x < y | - | == | Equal to: True if both operands are equal | x == y | - | != | Not equal to – True if operands are not equal | x != y | - | >= | Greater than or equal to: True if left operand is greater or equal | x >= y | - | <= | Less than or equal to: True if left operand is less than or equal | x <= y | + | Operator | Description | Syntax | + |----------|------------------------------------------------------------------------|-----------| + | > | Greater than: True if the left operand is greater than the right | x > y | + | < | Less than: True if the left operand is less than the right | x < y | + | == | Equal to: True if both operands are equal | x == y | + | != | Not equal to: True if operands are not equal | x != y | + | >= | Greater than or equal to: True if the left operand is greater or equal | x >= y | + | <= | Less than or equal to: True if the left operand is less or equal | x <= y | diff --git a/exercises/08.1-Your-First-If/solution.hide.py b/exercises/08.1-Your-First-If/solution.hide.py index 706c21fc..bb51f955 100644 --- a/exercises/08.1-Your-First-If/solution.hide.py +++ b/exercises/08.1-Your-First-If/solution.hide.py @@ -4,6 +4,6 @@ if total > 100: print("Give me your money!") elif total > 50: - print("Buy me some coffee you cheap!") + print("Buy me some coffee, you cheap!") else: - print("You are a poor guy, go away!") \ No newline at end of file + print("You are a poor guy, go away!") diff --git a/exercises/08.1-Your-First-If/test.py b/exercises/08.1-Your-First-If/test.py index 9d479ee5..8bda7fe2 100644 --- a/exercises/08.1-Your-First-If/test.py +++ b/exercises/08.1-Your-First-If/test.py @@ -31,37 +31,37 @@ def test_for_output_when_101(stdin, capsys, app): captured = capsys.readouterr() assert "Give me your money!\n" in captured.out -@pytest.mark.it("When input exactly 100 should print: Buy me some coffee you cheap ") +@pytest.mark.it("When input exactly 100 should print: Buy me some coffee, you cheap!") def test_for_output_when_100(capsys, app): with mock.patch('builtins.input', lambda x: 100): app() captured = capsys.readouterr() - assert "Buy me some coffee you cheap!\n" in captured.out + assert "Buy me some coffee, you cheap!\n" in captured.out -@pytest.mark.it("When input is 99 should print: Buy me some coffee you cheap ") +@pytest.mark.it("When input is 99 should print: Buy me some coffee, you cheap!") def test_for_output_when_99(capsys, app): with mock.patch('builtins.input', lambda x: 99): app() captured = capsys.readouterr() - assert "Buy me some coffee you cheap!\n" in captured.out + assert "Buy me some coffee, you cheap!\n" in captured.out -@pytest.mark.it("When input is 51 should print: Buy me some coffee you cheap ") +@pytest.mark.it("When input is 51 should print: Buy me some coffee, you cheap!") def test_for_output_when_51(capsys, app): with mock.patch('builtins.input', lambda x: 51): app() captured = capsys.readouterr() - assert "Buy me some coffee you cheap!\n" in captured.out + assert "Buy me some coffee, you cheap!\n" in captured.out -@pytest.mark.it("When input exactly 50 should print: You are a poor guy, go away") +@pytest.mark.it("When input exactly 50 should print: You are a poor guy, go away!") def test_for_output_when_50(capsys, app): with mock.patch('builtins.input', lambda x: 50): app() captured = capsys.readouterr() assert "You are a poor guy, go away!\n" in captured.out -@pytest.mark.it("When input less than 50 should print: You are a poor guy, go away") +@pytest.mark.it("When input less than 50 should print: You are a poor guy, go away!") def test_for_output_when_49(capsys, app): with mock.patch('builtins.input', lambda x: 49): app() captured = capsys.readouterr() - assert "You are a poor guy, go away!\n" in captured.out \ No newline at end of file + assert "You are a poor guy, go away!\n" in captured.out diff --git a/exercises/08.2-How-Much-The-Wedding-Costs/README.es.md b/exercises/08.2-How-Much-The-Wedding-Costs/README.es.md index 472fc950..37b763c1 100644 --- a/exercises/08.2-How-Much-The-Wedding-Costs/README.es.md +++ b/exercises/08.2-How-Much-The-Wedding-Costs/README.es.md @@ -1,4 +1,4 @@ -# `08.2` Cuánto costará la boda (if...else) +# `08.2` How Much The Wedding Costs (if...else) Aquí tenemos una tabla de precios de una compañía de catering de bodas: @@ -9,7 +9,7 @@ Aquí tenemos una tabla de precios de una compañía de catering de bodas: | Hasta 200 personas | $15,000 | | Más de 200 personas | $20,000 | ->Nota: Las cantidades en la tabla incluyen el número especificado. Por ejemplo, "Hasta 50 personas" incluye exactamente 50 personas. +> Nota: Las cantidades en la tabla incluyen el número especificado. Por ejemplo, "Hasta 50 personas" incluye exactamente 50 personas. ## 📝 Instrucciones: @@ -17,8 +17,8 @@ Aquí tenemos una tabla de precios de una compañía de catering de bodas: 2. Amplía el código proporcionado a la izquierda para cubrir todos los rangos posibles de invitados. 3. Asegúrate de que tu código calcule e imprima correctamente el precio en la consola según el input del usuario. -Por ejemplo, si la persona dice que `20` personas van a la boda, deberìa costar `$4,000` dólares. +Por ejemplo, si la persona dice que `20` personas van a la boda, debería costar `$4,000` dólares. ## 💡 Pista: -+ Usa if/else para dividir el código y definir el valor de la variable `price` de forma correcta. ++ Usa `if...else` para dividir el código y definir el valor de la variable `price` de forma correcta. diff --git a/exercises/08.2-How-Much-The-Wedding-Costs/README.md b/exercises/08.2-How-Much-The-Wedding-Costs/README.md index 58ecdd99..3fd1585e 100644 --- a/exercises/08.2-How-Much-The-Wedding-Costs/README.md +++ b/exercises/08.2-How-Much-The-Wedding-Costs/README.md @@ -25,4 +25,4 @@ For example, if the user says that `20` people are attending to the wedding, it ## 💡 Hint: -+ Use if/else to divide your code and set the value of the `price` variable the right way. ++ Use `if...else` to divide your code and set the value of the `price` variable the right way. diff --git a/exercises/08.2-How-Much-The-Wedding-Costs/test.py b/exercises/08.2-How-Much-The-Wedding-Costs/test.py index 9c36c672..4c1261d8 100644 --- a/exercises/08.2-How-Much-The-Wedding-Costs/test.py +++ b/exercises/08.2-How-Much-The-Wedding-Costs/test.py @@ -16,6 +16,7 @@ def test_for_print(capsys): regex2 = re.compile(r"elif\s*") assert bool(regex2.search(content)) == True + @pytest.mark.it("Between 101 and 200 guests sould be priced 15,000") def test__between_100_and_200(capsys, app): with mock.patch('builtins.input', lambda x: 200): @@ -24,6 +25,7 @@ def test__between_100_and_200(capsys, app): price = 15000 assert "Your wedding will cost "+str(price)+" dollars\n" in captured.out + @pytest.mark.it("Between 51 and 100 guests sould be priced 10,000") def test_between_101_and_51(capsys, app): with mock.patch('builtins.input', lambda x: 100): @@ -33,7 +35,7 @@ def test_between_101_and_51(capsys, app): assert "Your wedding will cost "+str(price)+" dollars\n" in captured.out -@pytest.mark.it("Less than 50 guests sould be priced 4,000") +@pytest.mark.it("Less than 50 guests, it should cost 4,000") def test_less_than_50(capsys, app): with mock.patch('builtins.input', lambda x: 50): app() @@ -41,10 +43,10 @@ def test_less_than_50(capsys, app): price = 4000 "Your wedding will cost "+str(price)+" dollars\n" in captured.out -@pytest.mark.it("More than 200 should be priced 20,000") +@pytest.mark.it("More than 200 guests, it should cost 20,000") def test_t(capsys, app): with mock.patch('builtins.input', lambda x: 201): app() captured = capsys.readouterr() price = 20000 - "Your wedding will cost "+str(price)+" dollars\n" in captured.out \ No newline at end of file + "Your wedding will cost "+str(price)+" dollars\n" in captured.out diff --git a/exercises/09-Random-Numbers/README.es.md b/exercises/09-Random-Numbers/README.es.md index da28bb47..b77ad09e 100644 --- a/exercises/09-Random-Numbers/README.es.md +++ b/exercises/09-Random-Numbers/README.es.md @@ -1,13 +1,13 @@ # `09` Random Numbers -Puedes usar la función `randint()`para obtener un número entero aleatorio. `randint()` es una funcion interna del módulo **random** en Python 3. +Puedes usar la función `randint()` para obtener un número entero aleatorio. `randint()` es una función interna del módulo `random` en Python3. -El módulo random da acceso a varias funciones útiles y una de ellas, la función `randint()`, genera números **enteros* aleatorios entre un rango que le pasemos por parámetro, por ejemplo: `randint(numMinimo, numMaximo)`. El numero minimo y el numero maximo en dicho rango son inclusivos. +El módulo random da acceso a varias funciones útiles y una de ellas, la función `randint()`, genera números **enteros** aleatorios entre un rango que le pasemos por parámetro, por ejemplo: `randint(num_minimo, num_maximo)`. El número mínimo y el número máximo en dicho rango son inclusivos. ## 📝 Instrucciones: -1. Actualmente el código está devolviendo números decimales aleatorios, por favor actualiza la función en el código para hacer que devuelva un número entero (no decimal) entre 1 y 10. +1. Actualmente, el código está devolviendo números decimales aleatorios, por favor actualiza la función en el código para hacer que devuelva un número entero (no decimal) entre 1 y 10. -## 💡 Pistas: +## 💡 Pista: -+ Puedes encontrar información addicional sobre el modulo random aquí: https://ellibrodepython.com/numeros-aleatorios-python \ No newline at end of file ++ Puedes encontrar información adicional sobre el módulo `random` aquí: https://ellibrodepython.com/numeros-aleatorios-python diff --git a/exercises/09-Random-Numbers/README.md b/exercises/09-Random-Numbers/README.md index 021fe0d8..fcfff339 100644 --- a/exercises/09-Random-Numbers/README.md +++ b/exercises/09-Random-Numbers/README.md @@ -4,9 +4,9 @@ tutorial: "https://www.youtube.com/watch?v=uYqMOZ-jFag" # `09` Random Numbers -You can use the `randint()` function to get a random integer number. `randint()` is an inbuilt function of the **random** module in Python3. +You can use the `randint()` function to get a random integer number. `randint()` is an inbuilt function of the `random` module in Python3. - The random module offers various useful functions, including `randint()`, which generates random **whole** numbers within a given range passed as parameters. You can use it like this: `randint(numMin, numMax)`, where both the minimum and maximum numbers are included in the range. +The random module offers various useful functions, including `randint()`, which generates random **whole** numbers within a given range passed as parameters. You can use it like this: `randint(min_num, max_num)`, where both the minimum and maximum numbers are included in the range. ## 📝 Instructions: @@ -14,4 +14,4 @@ You can use the `randint()` function to get a random integer number. `randint()` ## 💡 Hint: -+ For additional documentation on random module visit: https://www.tutorialsteacher.com/python/random-module \ No newline at end of file ++ For additional documentation on the `random` module, visit: https://www.tutorialsteacher.com/python/random-module diff --git a/exercises/10-Calling-Your-First-Function/README.es.md b/exercises/10-Calling-Your-First-Function/README.es.md index 70cc213f..29bc48a1 100644 --- a/exercises/10-Calling-Your-First-Function/README.es.md +++ b/exercises/10-Calling-Your-First-Function/README.es.md @@ -8,11 +8,11 @@ Las funciones son increíbles por muchas cosas, pero principalmente porque puede 2. La función `is_odd` está definida al inicio del código, por favor llama a esa función dentro de `my_main_code` pasándole el número `45345` e imprime el resultado en la consola. -## :mag_right: Importante: +## 🔎 Importante: - + Hay una serie de ejercicios dedicados a las funciones [aquí](https://github.com/4GeeksAcademy/python-functions-programming-exercises), te recomendamos realizarlos después de hacer **tu primera función** en este ejercicio. (luego..¡Regresa! :smiley:). ++ Hay una serie de ejercicios dedicados a las funciones [aquí](https://github.com/4GeeksAcademy/python-functions-programming-exercises), te recomendamos realizarlos después de hacer **tu primera función** en este ejercicio. (luego... ¡Regresa! 😃). - ## 💡Pista: +## 💡 Pista: - + Puedes consultar esta pagina para obtener información adicional sobre funciones y llamadas a funciones: https://www.freecodecamp.org/espanol/news/guia-de-funciones-de-python-con-ejemplos/ \ No newline at end of file ++ Puedes consultar esta página para obtener información adicional sobre funciones y llamadas a funciones: https://www.freecodecamp.org/espanol/news/guia-de-funciones-de-python-con-ejemplos/ diff --git a/exercises/10-Calling-Your-First-Function/README.md b/exercises/10-Calling-Your-First-Function/README.md index 7a19da1c..1db9a3c5 100644 --- a/exercises/10-Calling-Your-First-Function/README.md +++ b/exercises/10-Calling-Your-First-Function/README.md @@ -13,11 +13,11 @@ Functions are amazing because of many things, but mainly because you can encapsu 2. The function `is_odd` is defined at the beginning of the code, please call that function inside `my_main_code` passing it the number `45345` and print the result on the console. -## :mag_right: Important: +## 🔎 Important: -There's a series of exercises dedicated to Functions [here](https://github.com/4GeeksAcademy/python-functions-programming-exercises), we encourage you to go and finish those after your **first Function exercise** (And then... come back! :smiley). +There's a series of exercises dedicated to functions [here](https://github.com/4GeeksAcademy/python-functions-programming-exercises), we encourage you to go and finish those after your **first function exercise** (And then... come back! 😃). -## 💡Hint: +## 💡 Hint: -+ Check this out for additional information on functions and function calls: https://www.w3schools.com/python/python_functions.asp \ No newline at end of file ++ Check this out for additional information on functions and function calls: https://www.w3schools.com/python/python_functions.asp diff --git a/exercises/10-Calling-Your-First-Function/test.py b/exercises/10-Calling-Your-First-Function/test.py index 9deb6879..2544ae4b 100644 --- a/exercises/10-Calling-Your-First-Function/test.py +++ b/exercises/10-Calling-Your-First-Function/test.py @@ -29,7 +29,7 @@ def test_call_is_odd(): my_main_code() mocked_is_odd.assert_called_with(45345) -@pytest.mark.it('The console should output "True" inside the function my_main_code ') +@pytest.mark.it('The console should output "True" inside the function my_main_code') def test_for_file_output(capsys): from app import my_main_code my_main_code() diff --git a/exercises/10.1-Creating-Your-First-Function/README.es.md b/exercises/10.1-Creating-Your-First-Function/README.es.md index 52fa6f6a..978f547f 100644 --- a/exercises/10.1-Creating-Your-First-Function/README.es.md +++ b/exercises/10.1-Creating-Your-First-Function/README.es.md @@ -4,16 +4,15 @@ 1. La función `add_numbers` debería devolver la suma de 2 números dados. Por favor, completa el código necesario dentro de la función para hacer que se comporte como se espera. -2. Resultado esperado: el ejercicio debería escribir el número 7 en la cónsola. +2. Resultado esperado: el ejercicio debería escribir el número 7 en la consola. ## 💡 Pista: -+ Hay una función `add_numbers` ya declarada, que está recibiendo dos parámetros -(las variables `a` y `b`). Tú debes completar el contenido de la función con el código requerido para sumar la variable `a` con la variable `b` y devolver el resultado de la operación. ++ Hay una función `add_numbers` ya declarada, que está recibiendo dos parámetros (las variables `a` y `b`). Tú debes completar el contenido de la función con el código requerido para sumar la variable `a` con la variable `b` y devolver el resultado de la operación. ## 🔎 Importante: - + Para practicar con más funciones, 4Geeks Academy tiene más de 20 ejercicios que se incrementan en dificultad: [https://github.com/4GeeksAcademy/python-functions-programming-exercises](https://github.com/4GeeksAcademy/python-functions-programming-exercises). ++ Para practicar con más funciones, 4Geeks Academy tiene más de 20 ejercicios que se incrementan en dificultad: [https://github.com/4GeeksAcademy/python-functions-programming-exercises](https://github.com/4GeeksAcademy/python-functions-programming-exercises). -¡Inténtalos, y luego regresa!😃 +¡Inténtalos, y luego regresa! 😃 diff --git a/exercises/10.1-Creating-Your-First-Function/README.md b/exercises/10.1-Creating-Your-First-Function/README.md index cb233ddb..73faf321 100644 --- a/exercises/10.1-Creating-Your-First-Function/README.md +++ b/exercises/10.1-Creating-Your-First-Function/README.md @@ -6,20 +6,16 @@ tutorial: "https://www.youtube.com/watch?v=K0aDrl41SnQ" ## 📝 Instructions: -1. The function `add_numbers` is supposed to return the sum of 2 given numbers, please -complete the needed code inside of the function to make it behave as expected. +1. The function `add_numbers` is supposed to return the sum of 2 given numbers, please complete the needed code inside the function to make it behave as expected. -2. Expected Result: the exercise should print the number 7 in the console. +2. The exercise should print the number 7 in the console. ## 💡 Hint: -+ There is a function `"add_numbers"` already declared, it is receiving 2 parameters -(variables `a` and `b`), as a developer you were given a task to fill the -function content with the code needed to sum variable `a` with variable `b` and -return the result of that operation. ++ There is a function `add_numbers` already declared, it receives 2 parameters (variables `a` and `b`). As a developer, you were given the task to fill the function's body with the code needed to sum variable `a` with variable `b` and return the result of that operation. ## 🔎 Important: -For practicing with more functions, 4Geeks Academy has more than 20 exercises that increase in difficulty: [https://github.com/4GeeksAcademy/python-functions-programming-exercises](https://github.com/4GeeksAcademy/python-functions-programming-exercises). +For more practice with functions, 4Geeks Academy has more than 20 exercises that increase in difficulty: [https://github.com/4GeeksAcademy/python-functions-programming-exercises](https://github.com/4GeeksAcademy/python-functions-programming-exercises). -Try them, and then come back!😃 +Try them, and then come back! 😃 diff --git a/exercises/10.1-Creating-Your-First-Function/app.py b/exercises/10.1-Creating-Your-First-Function/app.py index bea9825c..4db5352c 100644 --- a/exercises/10.1-Creating-Your-First-Function/app.py +++ b/exercises/10.1-Creating-Your-First-Function/app.py @@ -1,6 +1,6 @@ -def addNumbers(a,b): - # This is the function body. ✅↓ Write your code here. ↓✅ +def add_numbers(a,b): + # This is the function's body ✅↓ Write your code here ↓✅ # ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌ -print(addNumbers(3,4)) +print(add_numbers(3,4)) diff --git a/exercises/10.1-Creating-Your-First-Function/solution.hide.py b/exercises/10.1-Creating-Your-First-Function/solution.hide.py index 619f2145..2d72fdd1 100644 --- a/exercises/10.1-Creating-Your-First-Function/solution.hide.py +++ b/exercises/10.1-Creating-Your-First-Function/solution.hide.py @@ -1,6 +1,6 @@ -def addNumbers(a,b): - # This is the function body. ✅↓ Write your code here. ↓✅ - return b + a +def add_numbers(a,b): + # This is the function's body ✅↓ Write your code here ↓✅ + return a + b # ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌ -print(addNumbers(3,4)) +print(add_numbers(3,4)) diff --git a/exercises/10.1-Creating-Your-First-Function/test.py b/exercises/10.1-Creating-Your-First-Function/test.py index ae4b341d..040c9c60 100644 --- a/exercises/10.1-Creating-Your-First-Function/test.py +++ b/exercises/10.1-Creating-Your-First-Function/test.py @@ -7,19 +7,19 @@ import sys path = os.path.dirname(os.path.abspath(__file__))+'/app.py' -@pytest.mark.it('The function addNumbers should exist') +@pytest.mark.it('The function add_numbers should exist') def test_for_function(): try: - app.addNumbers + app.add_numbers except AttributeError: - raise AttributeError("The function addNumbers should exist") + raise AttributeError("The function add_numbers should exist") @pytest.mark.it('Print the function in console with the values: 3, 4') def test_for_function_print(): with open(path, 'r') as content_file: content = content_file.read() - regex = re.compile(r"print\s*\(\s*addNumbers\s*\(\s*3\s*,\s*4\s*\)\s*\)") + regex = re.compile(r"print\s*\(\s*add_numbers\s*\(\s*3\s*,\s*4\s*\)\s*\)") assert bool(regex.search(content)) == True @@ -32,12 +32,12 @@ def test_for_print(): @pytest.mark.it('Function should sum the two given numbers') def test_for_return(): - from app import addNumbers - result = addNumbers(3,4) + from app import add_numbers + result = add_numbers(3,4) assert result == 7 @pytest.mark.it('Function should sum the two given numbers. Testing with different numbers') def test_for_return_2(): - from app import addNumbers - result = addNumbers(10,5) - assert result == 15 \ No newline at end of file + from app import add_numbers + result = add_numbers(10,5) + assert result == 15 diff --git a/exercises/11-Create-A-New-Function/README.es.md b/exercises/11-Create-A-New-Function/README.es.md index c1ae2f22..05923095 100644 --- a/exercises/11-Create-A-New-Function/README.es.md +++ b/exercises/11-Create-A-New-Function/README.es.md @@ -2,20 +2,19 @@ Como sabes, las funciones son un bloque de código útil que puedes reusar tantas veces como necesites. -En el último ejercicio, tenías una función que recibía dos parámetros -(dos entradas) y devolvía la suma de ellos. Así: +En el último ejercicio, tenías una función que recibía dos parámetros (dos entradas) y devolvía la suma de ellos. Así: ```py def add_numbers(a, b): - print(a + b) + print(a + b) ``` Pero Python viene con un conjunto de funciones "pre-definidas" que puedes usar, por ejemplo: ```py import random -# Genera un número aleatorio dentro -# de un rango posiivo dado +# Genera un número aleatorio dentro de un rango positivo dado + r1 = random.randint(0, 10) print("Random number between 0 and 10 is % s" % (r1)) ``` @@ -26,14 +25,14 @@ El **módulo random** te da acceso a varias funciones útiles y una de ellas es, ## 📝 Instrucciones: -1. Por favor, ahora crea una función llamada `generate_random` que devuelva un número aleatorio entre 0 y 9 cada vez que le llame. +1. Por favor, crea una función llamada `generate_random` que devuelva un número aleatorio entre 0 y 9 cada vez que se llame. 2. Imprime el resultado que la función retorna al ser llamada. ## 💡 Pistas: -+ Una posible solución involucra el uso de dos funciones predefinidas: las funciones `randint` o `randrange`. ++ Una posible solución involucra el uso de una de dos funciones predefinidas: la función `randint` o `randrange`. -+ No olvides importar el **módulo random**. ++ No olvides importar el módulo `random`. -+ Puedes consultar la documentación en: https://docs.python.org/3/library/random.html#functions-for-integers \ No newline at end of file ++ Puedes consultar la documentación en: https://docs.python.org/3/library/random.html#functions-for-integers diff --git a/exercises/11-Create-A-New-Function/README.md b/exercises/11-Create-A-New-Function/README.md index e79fc1e0..e09e2610 100644 --- a/exercises/11-Create-A-New-Function/README.md +++ b/exercises/11-Create-A-New-Function/README.md @@ -4,26 +4,26 @@ tutorial: "https://www.youtube.com/watch?v=XazswkTqKJI" # `11` Create a New Function -As you know, functions are a useful block of code that you can re-use as many times as you need. In the last exercise, you had a function that received two parameters (two inputs) and returned the sum of those. Like this: +As you know, functions are useful blocks of code that you can re-use as many times as you need. In the last exercise, you had a function that received two parameters (two inputs) and returned the sum of those. Like this: ```py def add_numbers(a, b): - print(a + b) + print(a + b) ``` But Python comes with a bunch of "pre-defined" functions that you can use, for example: ```py import random -# Generates a random number between -# a given positive range +# Generates a random number between a given positive range + r1 = random.randint(0, 10) print("Random number between 0 and 10 is % s" % (r1)) ``` You can use the `randint()` function to get a random whole number. `randint()` is an inbuilt function of the **random module** in Python3. -The **random module** gives access to various useful functions and one of them being able to generate random numbers, which is `randint()`. +The **random module** gives access to various useful functions, one of them being able to generate random numbers, which is `randint()`. ## 📝 Instructions: @@ -33,8 +33,8 @@ The **random module** gives access to various useful functions and one of them b ## 💡 Hints: -+ One possible solution involves using two predefined functions: the `randint()` or `randrange()` function. ++ One possible solution involves using one out of two predefined functions: the `randint()` or `randrange()` functions. -+ Don't forget to import the **random module**. ++ Don't forget to import the `random` module. -+ You can check the documentation here: https://docs.python.org/3/library/random.html#functions-for-integers \ No newline at end of file ++ You can check the documentation here: https://docs.python.org/3/library/random.html#functions-for-integers diff --git a/exercises/11-Create-A-New-Function/app.py b/exercises/11-Create-A-New-Function/app.py index ed1c5597..46b20099 100644 --- a/exercises/11-Create-A-New-Function/app.py +++ b/exercises/11-Create-A-New-Function/app.py @@ -1,3 +1,3 @@ import random -# ✅↓ Write your code here. ↓✅ +# ✅↓ Write your code here ↓✅ diff --git a/exercises/11-Create-A-New-Function/solution.hide.py b/exercises/11-Create-A-New-Function/solution.hide.py index 943706e3..ef03d021 100644 --- a/exercises/11-Create-A-New-Function/solution.hide.py +++ b/exercises/11-Create-A-New-Function/solution.hide.py @@ -1,6 +1,8 @@ import random -# ✅↓ Write your code here. ↓✅ +# ✅↓ Write your code here ↓✅ def generate_random(): result = random.randint(0,9) - return result \ No newline at end of file + return result + +print(generate_random()) diff --git a/exercises/11-Create-A-New-Function/test.py b/exercises/11-Create-A-New-Function/test.py index cb308b05..2872531b 100644 --- a/exercises/11-Create-A-New-Function/test.py +++ b/exercises/11-Create-A-New-Function/test.py @@ -14,7 +14,7 @@ def test_function_exists(): except ImportError: raise ImportError("The function 'generate_random' should exist on app.py") -@pytest.mark.it("The function 'generate_random' should return random number between 0 and 9") +@pytest.mark.it("The function 'generate_random' should return a random number between 0 and 9") def test_for_return(): from app import generate_random result = generate_random() @@ -31,9 +31,10 @@ def test_for_type_random(): regex2 = re.compile(r"random.randrange\s*\(") assert bool(regex.search(content)) == True or bool(regex2.search(content)) == True -@pytest.mark.it('You should be using print()') -def test_for_type_random(): +@pytest.mark.it('You should print() the output of the function') +def test_function_called_for(): + with open(path, 'r') as content_file: content = content_file.read() - - assert "print" in content + regex = re.compile(r"print\s*\(\s*generate_random\s*\(\s*\)\s*\)") + assert bool(regex.search(content)) == True diff --git a/exercises/12-Rand-From-One-to-Twelve/README.es.md b/exercises/12-Rand-From-One-to-Twelve/README.es.md index bcfae4d9..995d8094 100644 --- a/exercises/12-Rand-From-One-to-Twelve/README.es.md +++ b/exercises/12-Rand-From-One-to-Twelve/README.es.md @@ -10,4 +10,4 @@ + Debería imprimir números entre 1 y 12, no entre 0 y 12. -+ Este ejercicio es super simple, no te compliques!😃 \ No newline at end of file ++ Este ejercicio es super simple, ¡no te compliques! 😃 diff --git a/exercises/12-Rand-From-One-to-Twelve/README.md b/exercises/12-Rand-From-One-to-Twelve/README.md index cd12a399..ec81b66c 100644 --- a/exercises/12-Rand-From-One-to-Twelve/README.md +++ b/exercises/12-Rand-From-One-to-Twelve/README.md @@ -8,10 +8,10 @@ tutorial: "https://www.youtube.com/watch?v=EdyMlVlNUT0" 1. Change whatever you need to change to make the algorithm print random integers between 1 and 12. -2. This time use `randrange()`function. +2. This time use the `randrange()` function. ## 💡 Hints: + It should print between 1 and 12, not between 0 and 12. -+ This exercise is super simple, don't complicate yourself!😃 \ No newline at end of file ++ This exercise is super simple, don't complicate yourself! 😃 diff --git a/exercises/12-Rand-From-One-to-Twelve/app.py b/exercises/12-Rand-From-One-to-Twelve/app.py index 7b5483ce..d7304410 100644 --- a/exercises/12-Rand-From-One-to-Twelve/app.py +++ b/exercises/12-Rand-From-One-to-Twelve/app.py @@ -1,8 +1,8 @@ import random def get_randomInt(): - # ✅↓ Write your code here. ↓✅ + # ✅↓ Write your code here ↓✅ return None # ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌ -print(get_randomInt()) \ No newline at end of file +print(get_randomInt()) diff --git a/exercises/12-Rand-From-One-to-Twelve/solution.hide.py b/exercises/12-Rand-From-One-to-Twelve/solution.hide.py index 00d751b7..f1329ca0 100644 --- a/exercises/12-Rand-From-One-to-Twelve/solution.hide.py +++ b/exercises/12-Rand-From-One-to-Twelve/solution.hide.py @@ -1,9 +1,9 @@ import random def get_randomInt(): - # ✅↓ Write your code here. ↓✅ + # ✅↓ Write your code here ↓✅ random_number = random.randrange(1,13) return random_number # ❌ ↓ DON'T CHANGE THE CODE BELOW ↓ ❌ -print(get_randomInt()) \ No newline at end of file +print(get_randomInt()) diff --git a/exercises/12-Rand-From-One-to-Twelve/test.py b/exercises/12-Rand-From-One-to-Twelve/test.py index fe26718e..ed078ffe 100644 --- a/exercises/12-Rand-From-One-to-Twelve/test.py +++ b/exercises/12-Rand-From-One-to-Twelve/test.py @@ -16,7 +16,7 @@ def test_function_existence(app): except AttributeError: raise AttributeError("The function get_randomInt should exist") -@pytest.mark.it("Check that you are setting the correct values for the randrange function.") +@pytest.mark.it("Check that you are setting the correct values for the randrange function") def test_conditional(): with open(path, 'r') as content_file: content = content_file.read() @@ -29,7 +29,7 @@ def test_print_output(capsys, app): result = app.get_randomInt() assert result >= 1 or result <= 12 -@pytest.mark.it('You must call the function inside the print() function.') +@pytest.mark.it('You must call the function inside the print() function') def test_function_called_for(): with open(path, 'r') as content_file: content = content_file.read() diff --git a/exercises/13-Create-A-For-Loop/README.es.md b/exercises/13-Create-A-For-Loop/README.es.md index 791965dc..b4e8b89f 100644 --- a/exercises/13-Create-A-For-Loop/README.es.md +++ b/exercises/13-Create-A-For-Loop/README.es.md @@ -1,6 +1,6 @@ # `13` Create A For Loop -Los bucles o loops son muy útiles... No tienes que reescribir las mismas líneas muchas veces. +Los bucles o loops son muy útiles. No tienes que reescribir las mismas líneas muchas veces. El bucle o loop `for` te permite ejecutar el mismo código varias veces para diferentes valores. @@ -8,7 +8,7 @@ El bucle o loop `for` te permite ejecutar el mismo código varias veces para dif 1. Completa la función llamada `standards_maker()`. -2. La función tiene que imprimir 300 veces la frase "Escribiré preguntas si estoy atascado". +2. La función tiene que imprimir 300 veces la frase "Haré preguntas si estoy atascado". 3. Llama a la función `standards_maker()`. @@ -18,4 +18,4 @@ El bucle o loop `for` te permite ejecutar el mismo código varias veces para dif ## 🔎 Importante: -+ Puedes leer más al respecto aquí: https://ellibrodepython.com/for-python \ No newline at end of file ++ Puedes leer más al respecto aquí: https://ellibrodepython.com/for-python diff --git a/exercises/13-Create-A-For-Loop/README.md b/exercises/13-Create-A-For-Loop/README.md index 22af4705..6a1acb10 100644 --- a/exercises/13-Create-A-For-Loop/README.md +++ b/exercises/13-Create-A-For-Loop/README.md @@ -4,7 +4,7 @@ tutorial: "https://www.youtube.com/watch?v=-HQtwsBnbMQ" # `13` Create A For Loop -Loops are very useful... You don't have to rewrite the same lines many times. +Loops are very useful. You don't have to rewrite the same lines many times. The `for` loop lets you run the same code for different values. @@ -12,7 +12,7 @@ The `for` loop lets you run the same code for different values. 1. Complete the function called `standards_maker`. -2. The function has to print 300 times the phrase "I will write questions if I am stuck". +2. The function has to print 300 times the phrase "I will ask questions if I am stuck". 3. Call the function `standards_maker()`. @@ -22,4 +22,4 @@ The `for` loop lets you run the same code for different values. ## 🔎 Important: -+ Read more on loops: https://www.w3schools.com/python/python_for_loops.asp \ No newline at end of file ++ Read more on loops: https://www.w3schools.com/python/python_for_loops.asp diff --git a/exercises/13-Create-A-For-Loop/app.py b/exercises/13-Create-A-For-Loop/app.py index cc52a510..19631c70 100644 --- a/exercises/13-Create-A-For-Loop/app.py +++ b/exercises/13-Create-A-For-Loop/app.py @@ -1,5 +1,5 @@ def standards_maker(): - # ✅↓ Write your code here. ↓✅ + # ✅↓ Write your code here ↓✅ -# ✅↓ remember to call the function outside (here) ↓✅ \ No newline at end of file +# ✅↓ remember to call the function outside (here) ↓✅ diff --git a/exercises/13-Create-A-For-Loop/solution.hide.py b/exercises/13-Create-A-For-Loop/solution.hide.py index a616c235..2dd3965a 100644 --- a/exercises/13-Create-A-For-Loop/solution.hide.py +++ b/exercises/13-Create-A-For-Loop/solution.hide.py @@ -1,7 +1,7 @@ def standards_maker(): - # ✅↓ Write your code here. ↓✅ + # ✅↓ Write your code here ↓✅ for i in range(0, 300): - print("I will write questions if I am stuck") + print("I will ask questions if I am stuck") # ✅↓ remember to call the function outside (here) ↓✅ -standards_maker() \ No newline at end of file +standards_maker() diff --git a/exercises/13-Create-A-For-Loop/test.py b/exercises/13-Create-A-For-Loop/test.py index bac75fb6..7c108916 100644 --- a/exercises/13-Create-A-For-Loop/test.py +++ b/exercises/13-Create-A-For-Loop/test.py @@ -9,7 +9,7 @@ import re path = os.path.dirname(os.path.abspath(__file__))+'/app.py' -@pytest.mark.it("You should declare a function named standards_maker") +@pytest.mark.it("You should define a function named standards_maker") def test_variable_exists(): try: from app import standards_maker @@ -23,11 +23,11 @@ def test_for_loop(): regex = re.compile(r"for") assert bool(regex.search(content)) == True -@pytest.mark.it("You should include in the function standards_maker a for loop which prints the string in the instructions 300 times") +@pytest.mark.it("In the function standards_maker include a for loop which prints the string in the instructions 300 times") def test_for_file_output(capsys): captured = buffer.getvalue() - expected = ["I will write questions if I am stuck\n" for x in range(300)] - expected_2 = ["Escribiré preguntas si estoy atascado\n" for x in range(300)] + expected = ["I will ask questions if I am stuck\n" for x in range(300)] + expected_2 = ["Haré preguntas si estoy atascado\n" for x in range(300)] hasCorrectAnswer = ((captured == "".join(expected)) or (captured == "".join(expected_2))) @@ -40,7 +40,7 @@ def test_for_print(): regex = re.compile(r"print\s*\(.+\)") assert bool(regex.search(content)) == True -@pytest.mark.it("You should call the function standards_maker ") +@pytest.mark.it("You should call the function standards_maker") def test_callTheFunction(): with open(path, 'r') as content_file: content = content_file.read() diff --git a/exercises/14-Your-First-Loop/README.es.md b/exercises/14-Your-First-Loop/README.es.md index cfd69ae6..7e28efe6 100644 --- a/exercises/14-Your-First-Loop/README.es.md +++ b/exercises/14-Your-First-Loop/README.es.md @@ -1,16 +1,16 @@ # `14` Your First Loop -## 📝 Instrucciones: +## 📝 Instrucciones: -1. Ejecuta este código, verás una cuenta de 0 a 9 (caracteres blancos). +1. Ejecuta este código, verás una cuenta de 0 a 9. 2. Corrígelo para que cuente hasta 11. ## 🔎 Importante: -+ Hay una serie de ejercicios dedicados a listas y bucles o loops, te invitamos a realizarlos antes de continuar: [https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises). ++ Hay una serie de ejercicios dedicados a listas y bucles, te invitamos a realizarlos antes de continuar: [https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises). -!Luego, regresa!😊 +¡Luego, regresa! 😊 ## 💡 Pista: -+ Puedes encontrar información adicional aquí: https://tutorial.recursospython.com/bucles/ \ No newline at end of file ++ Puedes encontrar información adicional aquí: https://tutorial.recursospython.com/bucles/ diff --git a/exercises/14-Your-First-Loop/README.md b/exercises/14-Your-First-Loop/README.md index 990b2bd4..af03d283 100644 --- a/exercises/14-Your-First-Loop/README.md +++ b/exercises/14-Your-First-Loop/README.md @@ -4,17 +4,17 @@ tutorial: "https://www.youtube.com/watch?v=30sizcnVdGg" # `14` Your First Loop -## 📝 Instructions: +## 📝 Instructions: -1. Run this code, you'll see a count from 0 to 9 (White characters). +1. Run this code, and you'll see a count from 0 to 9. 2. Fix it so that it counts up to 11. -## 🔎 Important: +## 🔎 Important: + There's a series of exercises dedicated to Lists and Loops, we encourage you to go and finish those before continuing: [https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises). -Then, come back!😊 +Then, come back! 😊 -## 💡Hint: -+ You can find additional information on loops here: https://www.w3schools.com/python/python_for_loops.asp \ No newline at end of file +## 💡 Hint: ++ You can find additional information on loops here: https://www.w3schools.com/python/python_for_loops.asp diff --git a/exercises/14-Your-First-Loop/test.py b/exercises/14-Your-First-Loop/test.py index 51b6b831..c936b923 100644 --- a/exercises/14-Your-First-Loop/test.py +++ b/exercises/14-Your-First-Loop/test.py @@ -22,9 +22,9 @@ def test_for_function_output(capsys): captured = capsys.readouterr() assert "0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n" in captured.out -@pytest.mark.it('Use for loop') +@pytest.mark.it('Use a for loop') def test_for_loop(): with open(path, 'r') as content_file: content = content_file.read() regex = re.compile(r"for\s*") - assert bool(regex.search(content)) == True \ No newline at end of file + assert bool(regex.search(content)) == True diff --git a/exercises/15-Looping-With-FizzBuzz/README.es.md b/exercises/15-Looping-With-FizzBuzz/README.es.md index 5e0706c6..fbaa200d 100644 --- a/exercises/15-Looping-With-FizzBuzz/README.es.md +++ b/exercises/15-Looping-With-FizzBuzz/README.es.md @@ -6,7 +6,13 @@ Esta es una típica prueba de principiante que es exigida para las entrevistas e 1. Escribe el código necesario para imprimir en la consola todos los números del 1 al 100. -## Resultado esperado: +2. Para múltiplos de 3, en lugar de imprimir el número, imprime "Fizz". + +3. Para múltiplos de 5, imprime "Buzz". + +4. Para números que son múltiplos de 3 y de 5, imprime "FizzBuzz". + +## 💻 Resultado esperado: ```py 1 @@ -34,16 +40,14 @@ Buzz ## 🔎 Importante: -+ Hay una serie de ejercicios dedicados a listas y ciclos, te invitamos a realizarlos antes de continuar: [https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises). +Hay una serie de ejercicios dedicados a listas y bucles, te invitamos a realizarlos antes de continuar: [https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises). -¡Luego, regresa!😊 +¡Luego, regresa! 😊 ## 💡 Pistas: -+ Para múltiplos de 3, en lugar de imprimir el número, imprime "Fizz". - -+ Para múltiplos de 5, imprime "Buzz". ++ Debes usar instrucciones `if`. -+ Para números que son múltiplos de 3 y de 5, imprime "FizzBuzz". ++ Piensa en el orden correcto de esos `if` para hacer que tu código haga lo que quieres. diff --git a/exercises/15-Looping-With-FizzBuzz/README.md b/exercises/15-Looping-With-FizzBuzz/README.md index 97b52c0f..a1e308dc 100644 --- a/exercises/15-Looping-With-FizzBuzz/README.md +++ b/exercises/15-Looping-With-FizzBuzz/README.md @@ -4,13 +4,19 @@ tutorial: "https://www.youtube.com/watch?v=fw3ukgmlSwQ" # `15` Looping With FizzBuzz -This is a typical beginner test that is required to complete interviews in Google, Facebook and all the other big tech companies. +This is a typical beginner test that is required to complete interviews at Google, Facebook and all the other big tech companies. ## 📝 Instructions: 1. Write the code needed to print in the console all the numbers from 1 to 100. + +2. For multiples of 3, instead of the number, print "Fizz". + +3. For multiples of 5, print "Buzz". + +4. For numbers that are multiples of both 3 and 5, print "FizzBuzz". -## Expected result: +## 💻 Expected result: ```py 1 @@ -41,12 +47,10 @@ Buzz There's a series of exercises dedicated to Lists and Loops, we encourage you to go and finish them before continuing: [https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises](https://github.com/4GeeksAcademy/python-lists-loops-programming-exercises) -Then, come back!😊 +Then, come back! 😊 -## 💡 Hints: +## 💡 Hint: -+ For multiples of 3, instead of the number, print "Fizz". - -+ For multiples of 5, print "Buzz". ++ You have to use multiple `if` statements. -+ For numbers which are multiples of both 3 and 5, print "FizzBuzz". \ No newline at end of file ++ Think about the correct order of the different `if` statements to make the code do what you want. diff --git a/exercises/15-Looping-With-FizzBuzz/app.py b/exercises/15-Looping-With-FizzBuzz/app.py index 31d72741..fff86955 100644 --- a/exercises/15-Looping-With-FizzBuzz/app.py +++ b/exercises/15-Looping-With-FizzBuzz/app.py @@ -1,5 +1,5 @@ def fizz_buzz(): - # ✅↓ Write your code here. ↓✅ + # ✅↓ Write your code here ↓✅ # ❌↓ DON'T CHANGE THE CODE BELOW ↓❌ -fizz_buzz() \ No newline at end of file +fizz_buzz() diff --git a/exercises/15-Looping-With-FizzBuzz/solution.hide.py b/exercises/15-Looping-With-FizzBuzz/solution.hide.py index 2ae1311c..b01fb63d 100644 --- a/exercises/15-Looping-With-FizzBuzz/solution.hide.py +++ b/exercises/15-Looping-With-FizzBuzz/solution.hide.py @@ -1,5 +1,5 @@ def fizz_buzz(): - # ✅↓ Write your code here. ↓✅ + # ✅↓ Write your code here ↓✅ for i in range(1, 101): if i % 3 == 0 and i % 5 == 0: print("FizzBuzz") @@ -11,4 +11,4 @@ def fizz_buzz(): print(i) # ❌↓ DON'T CHANGE THE CODE BELOW ↓❌ -fizz_buzz() \ No newline at end of file +fizz_buzz() diff --git a/exercises/15-Looping-With-FizzBuzz/test.py b/exercises/15-Looping-With-FizzBuzz/test.py index 5d8187c2..b8ecd541 100644 --- a/exercises/15-Looping-With-FizzBuzz/test.py +++ b/exercises/15-Looping-With-FizzBuzz/test.py @@ -16,14 +16,14 @@ def test_function_existence(): except AttributeError: raise AttributeError('The function fizz_buzz should exist') -@pytest.mark.it('Use for loop') +@pytest.mark.it('Use a for loop') def test_for_loop(): with open(path, 'r') as content_file: content = content_file.read() regex = re.compile(r"for\s*") assert bool(regex.search(content)) == True -@pytest.mark.it('2. Your function needs to print the correct output') +@pytest.mark.it('Your function needs to print the correct output') def test_for_function_output(capsys): fizz_buzz() captured = capsys.readouterr() diff --git a/exercises/16-Random-Colors-Loop/README.es.md b/exercises/16-Random-Colors-Loop/README.es.md index bbb78609..493f0c12 100644 --- a/exercises/16-Random-Colors-Loop/README.es.md +++ b/exercises/16-Random-Colors-Loop/README.es.md @@ -1,8 +1,8 @@ # `16` Random Colors (Loop) -Hemos creado una función que devuelve un color basado en un número entre 0 y 3 (cualquier número diferente, debe retornar el color `black` (negro)). +Hemos creado una función que devuelve un color basado en un número entre 0 y 3 (cualquier otro número retornará el color `black`). -Digamos que somos profesores en un aula con 10 estudiantes y queremos asignar a **cada estudiante** un color aleatorio entre `red` (rojo), `yellow` (amarillo), `blue` (azul) y `green` (verde). +Supongamos que somos profesores en un aula con 10 estudiantes y queremos asignar a **cada estudiante** un color aleatorio entre `red`, `yellow`, `blue` y `green`. (solo 1 color por estudiante) @@ -16,6 +16,6 @@ Digamos que somos profesores en un aula con 10 estudiantes y queremos asignar a + En cada iteración, genera un número aleatorio entre 0 y 3 usando la función `randint()` que hemos visto en ejercicios anteriores. -+ Usa la función `get_color`, en este ejercicio para saber qué color le corresponde al número obtenido. ++ Usa la función `get_color` en este ejercicio, para saber qué color le corresponde al número obtenido. -+ Llama (ejecuta) la funcion `get_allStudentColors` e imprime su resultado en la consola. \ No newline at end of file ++ Llama (ejecuta) la función `get_allStudentColors` e imprime su resultado en la consola. diff --git a/exercises/16-Random-Colors-Loop/README.md b/exercises/16-Random-Colors-Loop/README.md index 2c906d3b..e72e5e9f 100644 --- a/exercises/16-Random-Colors-Loop/README.md +++ b/exercises/16-Random-Colors-Loop/README.md @@ -6,13 +6,13 @@ tutorial: "https://www.youtube.com/watch?v=8zH3JT3AuAw" We have created a function that returns a color based on a number between 0 and 3 (for any different number, it will return the color `black`). -Let's say that we are teachers in a 10 student classroom and we want to randomly assign ONE color, between `red`, `yellow`, `blue` and `green`, to EACH student. +Let's say that we are teachers in a 10 student classroom, and we want to randomly assign ONE color, between `red`, `yellow`, `blue` and `green`, to EACH student. (only 1 color per student) ## 📝 Instructions: -1. Change the function `get_allStudentColors` so it returns a list of 10 colors, were each item in the list represents the color assigned to each student. +1. Change the function `get_allStudentColors` so it returns a list of 10 colors, where each item in the list represents the color assigned to each student. ## 💡 Hints: @@ -20,6 +20,6 @@ Let's say that we are teachers in a 10 student classroom and we want to randomly - In each iteration, generate a random number between 0 and 3 using the `randint()` function that we have seen in previous exercises. -- Use the `get_color` function, in this exercise to find out what color corresponds to the number obtained. +- Use the `get_color` function in this exercise, to find out what color corresponds to the number obtained. -- Call (execute) the function `get_allStudentColors` and print its result in the console. \ No newline at end of file +- Call (execute) the function `get_allStudentColors` and print its result in the console. diff --git a/exercises/16-Random-Colors-Loop/app.py b/exercises/16-Random-Colors-Loop/app.py index 5753c14a..0e29ead7 100644 --- a/exercises/16-Random-Colors-Loop/app.py +++ b/exercises/16-Random-Colors-Loop/app.py @@ -1,16 +1,17 @@ import random def get_color(color_number=4): - # making sure is a number and not a string + # Making sure is a number and not a string color_number = int(color_number) - switcher={ + switcher = { 0:'red', 1:'yellow', 2:'blue', 3:'green', 4:'black' } + return switcher.get(color_number,"Invalid Color Number") # ❌ ⬆ DON'T CHANGE THE CODE ABOVE ⬆ ❌ @@ -19,6 +20,6 @@ def get_allStudentColors(): example_color = get_color(1) students_array = [] # ✅ ↓ your loop here ↓ ✅ + - -print(get_allStudentColors()) \ No newline at end of file +print(get_allStudentColors()) diff --git a/exercises/16-Random-Colors-Loop/solution.hide.py b/exercises/16-Random-Colors-Loop/solution.hide.py index 17b87502..caa17fb9 100644 --- a/exercises/16-Random-Colors-Loop/solution.hide.py +++ b/exercises/16-Random-Colors-Loop/solution.hide.py @@ -1,16 +1,17 @@ import random def get_color(color_number=4): - # making sure is a number and not a string + # Making sure is a number and not a string color_number = int(color_number) - switcher={ + switcher = { 0:'red', 1:'yellow', 2:'blue', 3:'green', 4:'black' } + return switcher.get(color_number,"Invalid Color Number") # ❌ ⬆ DON'T CHANGE THE CODE ABOVE ⬆ ❌ @@ -25,4 +26,4 @@ def get_allStudentColors(): return students_array -print(get_allStudentColors()) \ No newline at end of file +print(get_allStudentColors()) diff --git a/exercises/16-Random-Colors-Loop/test.py b/exercises/16-Random-Colors-Loop/test.py index a25b67aa..e5585d70 100644 --- a/exercises/16-Random-Colors-Loop/test.py +++ b/exercises/16-Random-Colors-Loop/test.py @@ -31,11 +31,11 @@ def test_black_in_array(capsys, app): result = app.get_allStudentColors() assert result.count("black") == 0 -@pytest.mark.it('You should use for to iterate 10 times') +@pytest.mark.it('You should use a for loop to iterate 10 times') def use_for_loop(capsys): path = os.path.dirname(os.path.abspath(__file__))+'/app.py' with open(path, 'r') as content_file: content = content_file.read() pattern = r"for\s*" regex = re.compile(pattern) - assert bool(regex.search(content)) == True \ No newline at end of file + assert bool(regex.search(content)) == True diff --git a/exercises/17-Russian-Roulette/README.es.md b/exercises/17-Russian-Roulette/README.es.md index f6b4e500..25da2194 100644 --- a/exercises/17-Russian-Roulette/README.es.md +++ b/exercises/17-Russian-Roulette/README.es.md @@ -2,18 +2,20 @@ ¿Has jugado a la ruleta rusa? ¡Es muy divertido! Si no pierdes... (¡¡¡muuuajajajaja!!!). -Un revolver tiene seis orificios para balas... inserta una bala en uno de los orificios, -gira la cámara del revolver para hacer aleatorio el juego. Nadie sabrá dónde está la bala. +Un revolver tiene seis recámaras para balas... inserta una bala en una de las recámaras, gira el tambor del revolver para hacer aleatorio el juego. Nadie sabrá dónde está la bala. -¡¡¡FUEGO!!!....... ¿has muerto? +¡¡¡FUEGO!!!...... ¿Has muerto? ## 📝 Instrucciones: + 1. El juego casi funciona, por favor completa la función `fire_gun` para que el juego funcione. 2. Compara la posición de la bala con la posición de la recámara. 3. Si la posición de la bala es igual a la posición de la recámara, entonces la función debe retornar `You are dead!`, de lo contrario, debe retornar `Keep playing!` -## 💡 Pista: -- Puedes obtener la posición de la recámara llamando a la función `spin_chamber`. -- Si la bala está en el mismo compartimento que la recámara del revólver, entonces será disparada (`You are dead!`). \ No newline at end of file +## 💡 Pistas: + +- Puedes obtener la posición de la recámara llamando a la función `spin_chamber`. + +- Si la bala está en el mismo compartimento que la recámara del revólver, entonces será disparada (`You are dead!`). diff --git a/exercises/17-Russian-Roulette/README.md b/exercises/17-Russian-Roulette/README.md index 43228267..f3a4aaab 100644 --- a/exercises/17-Russian-Roulette/README.md +++ b/exercises/17-Russian-Roulette/README.md @@ -2,10 +2,9 @@ Have you ever played Russian Roulette? It's super fun! If you make it (muahahahaha). -The revolver gun has only 6 slots for bullets... insert one bullet in one of the slots, -spin the revolver chamber to make the game random, nobody knows the bullet position. +The revolver gun has only 6 slots for bullets... insert one bullet in one of the slots, spin the revolver chamber to make the game random, nobody knows the bullet position. -FIRE!!!....... are you dead? +FIRE!!!...... are you dead? ## 📝 Instructions: @@ -13,10 +12,10 @@ FIRE!!!....... are you dead? 2. Compare the bullet position against the chamber position. -3. If the bullet position is equal to the chamber position then the function should return `You are dead!`, else it should return `Keep playing!` +3. If the bullet position is equal to the chamber position, then the function should return `You are dead!`, else it should return `Keep playing!` -## 💡 Hint: +## 💡 Hints: + You can get the chamber position by calling the `spin_chamber` function -+ If the bullet is at the same slot as the revolver chamber, then it will be fired (`You are dead!`). \ No newline at end of file ++ If the bullet is at the same slot as the revolver chamber, then it will be fired (`You are dead!`). diff --git a/exercises/17-Russian-Roulette/app.py b/exercises/17-Russian-Roulette/app.py index d0503ccc..e8704639 100644 --- a/exercises/17-Russian-Roulette/app.py +++ b/exercises/17-Russian-Roulette/app.py @@ -8,8 +8,8 @@ def spin_chamber(): # ❌ ⬆ DON'T CHANGE THE CODE ABOVE ⬆ ❌ def fire_gun(): - # ✅ ↓ your loop here ↓ ✅ + # ✅ ↓ your code here ↓ ✅ return None -print(fire_gun()) \ No newline at end of file +print(fire_gun()) diff --git a/exercises/17-Russian-Roulette/solution.hide.py b/exercises/17-Russian-Roulette/solution.hide.py index afdfddeb..15e0e350 100644 --- a/exercises/17-Russian-Roulette/solution.hide.py +++ b/exercises/17-Russian-Roulette/solution.hide.py @@ -10,8 +10,8 @@ def spin_chamber(): def fire_gun(): # ✅ ↓ your loop here ↓ ✅ if spin_chamber() == bullet_position: - return "You're dead!" + return "You are dead!" else: return "Keep playing!" -print(fire_gun()) \ No newline at end of file +print(fire_gun()) diff --git a/exercises/18-The-Beatles/README.es.md b/exercises/18-The-Beatles/README.es.md index b58308bf..d0fa4cf3 100644 --- a/exercises/18-The-Beatles/README.es.md +++ b/exercises/18-The-Beatles/README.es.md @@ -6,20 +6,36 @@ Un estudio de la BBC ha probado que el 90% de los niños y niñas no conocen la Este es el coro de una de las canciones más famosas de la banda: -> Let it be, let it be, let it be, let it be, -> Whisper words of wisdom, +> Let it be, let it be, let it be, let it be, +> +> Whisper words of wisdom, +> > Let it be ## 📝 Instrucciones: -1. Crea una función llamada `sing()` que retorne un string con la misma letra que puedes escuchar desde el segundo 3:10 hasta el final de la canción en el segundo 3:54 https://www.youtube.com/watch?v=QDYfEBY9NM4. +1. Crea una función llamada `sing()` que imprima en consola la misma letra que puedes escuchar desde el segundo 3:21 hasta el final de la canción en el segundo 3:50 https://www.youtube.com/watch?v=QDYfEBY9NM4 -## Resultado esperado: +2. Llama tu función al final del código. -`let it be, let it be, let it be, let it be, whisper words of wisdom, let it be, let it be, let it be, let it be, let it be, there will be an answer, let it be` +## 💻 Resultado esperado: -## 💡 Pista: +```text +let it be, +let it be, +let it be, +let it be, +there will be an answer, +let it be, +let it be, +let it be, +let it be, +let it be, +whisper words of wisdom, let it be +``` -+ La frase "let it be" se repite todo el tiempo. Probablemente deberías usar un bucle o loop para eso 😊 +## 💡 Pistas: + ++ La frase "let it be" se repite todo el tiempo. Probablemente, deberías usar un bucle o loop para eso. 😊 + Si necesitas un repaso sobre los loops y/o condicionales, échale un vistazo a esto: https://docs.python.org/es/3/tutorial/controlflow.html diff --git a/exercises/18-The-Beatles/README.md b/exercises/18-The-Beatles/README.md index af3a8a78..10fa952b 100644 --- a/exercises/18-The-Beatles/README.md +++ b/exercises/18-The-Beatles/README.md @@ -8,22 +8,38 @@ Who does not like The Beatles? A BBC study has proved that 90% of kids don't know the band... so sad. :( -This is the chorus of one of the most famous Beatle songs: +This is the chorus of one of the most famous Beatles songs: -> Let it be, let it be, let it be, let it be, -> Whisper words of wisdom, +> Let it be, let it be, let it be, let it be, +> +> Whisper words of wisdom, +> > Let it be ## 📝 Instructions: -1. Create a function called `sing()` that returns a string with the exact same lyrics you can hear from the 3:10 sec to the end of the song at 3:54 sec https://www.youtube.com/watch?v=QDYfEBY9NM4. +1. Create a function called `sing()` that prints on the console the lyrics that you can hear from 3:21 sec to the end of the song at 3:50 sec https://www.youtube.com/watch?v=QDYfEBY9NM4 + +2. Call your function at the end. -## Expected output: +## 💻 Expected output: -`let it be, let it be, let it be, let it be, whisper words of wisdom, let it be, let it be, let it be, let it be, let it be, there will be an answer, let it be` +```text +let it be, +let it be, +let it be, +let it be, +there will be an answer, +let it be, +let it be, +let it be, +let it be, +let it be, +whisper words of wisdom, let it be +``` -## 💡 Hint: +## 💡 Hints: + The words "let it be" repeat all the time, you should probably create a loop for that. -+ If you need a refresher on loops and conditionals, check out this awesome resource: https://docs.python.org/3/tutorial/controlflow.html \ No newline at end of file ++ If you need a refresher on loops and conditionals, check out this awesome resource: https://docs.python.org/3/tutorial/controlflow.html diff --git a/exercises/18-The-Beatles/app.py b/exercises/18-The-Beatles/app.py index fd8b3103..d87e6fa1 100644 --- a/exercises/18-The-Beatles/app.py +++ b/exercises/18-The-Beatles/app.py @@ -1,2 +1,2 @@ -# ✅↓ Write your code here. ↓✅ +# ✅↓ Write your code here ↓✅ diff --git a/exercises/18-The-Beatles/solution.hide.py b/exercises/18-The-Beatles/solution.hide.py index 1088905d..49901bf0 100644 --- a/exercises/18-The-Beatles/solution.hide.py +++ b/exercises/18-The-Beatles/solution.hide.py @@ -1,13 +1,12 @@ -# ✅↓ Write your code here. ↓✅ +# ✅↓ Write your code here ↓✅ def sing(): - song = "" for i in range(11): if i == 4: - song += "whisper words of wisdom, " + print("there will be an answer,") elif i == 10: - song += "there will be an answer, let it be" + print("whisper words of wisdom, let it be") else: - song += "let it be, " - return song + print("let it be,") + return None -print(sing()) \ No newline at end of file +sing() diff --git a/exercises/18-The-Beatles/test.py b/exercises/18-The-Beatles/test.py index 0ebe1f60..d452f892 100644 --- a/exercises/18-The-Beatles/test.py +++ b/exercises/18-The-Beatles/test.py @@ -8,7 +8,7 @@ import re import os -@pytest.mark.it("You should declare a function named sing and call it in the correct way") +@pytest.mark.it("You should declare a function named sing()") def test_function_sing_exists(app): try: assert app.sing @@ -23,9 +23,9 @@ def test_function_hardcode_output(): regex = re.compile(r"\breturn\s*[^\"][a-zA-Z0-9]*\b\s*") assert bool(regex.search(content)) == True -@pytest.mark.it("The function sing should return astring with the song lyrics") +@pytest.mark.it("The function sing() should return a string with the song lyrics") def test_function_sing_exists(app): try: - assert app.sing() == "let it be, let it be, let it be, let it be, whisper words of wisdom, let it be, let it be, let it be, let it be, let it be, there will be an answer, let it be" + assert app.sing() == "let it be,\nlet it be,\nlet it be,\nlet it be,\nthere will be an answer,\nlet it be,\nlet it be,\nlet it be,\nlet it be,\nlet it be,\nwhisper words of wisdom, let it be" except AttributeError: - raise AttributeError("The function 'sing' should exist on app.py") \ No newline at end of file + raise AttributeError("The function 'sing' should exist on app.py") diff --git a/exercises/19-Bottles-Of-Milk/README.es.md b/exercises/19-Bottles-Of-Milk/README.es.md index e571c6a7..3df3fb1e 100644 --- a/exercises/19-Bottles-Of-Milk/README.es.md +++ b/exercises/19-Bottles-Of-Milk/README.es.md @@ -8,13 +8,13 @@ Aquí puedes escucharla: https://www.youtube.com/watch?v=Xy-da43E6Lo 1. Por favor, declara una función llamada `number_of_bottles()`. -2. La función necesita **print** para imprimir la letra exacta de la canción (usa el método `print()` y no `return`). +2. La función necesita imprimir la letra exacta de la canción (usa el método `print()` y no `return`). -## Resultado esperado: +## 💻 Resultado esperado: El resultado debería ser algo como esto: -```sh +```text 99 bottles of milk on the wall, 99 bottles of milk. Take one down and pass it around, 98 bottles of milk on the wall. @@ -32,8 +32,8 @@ No more bottles of milk on the wall, no more bottles of milk. Go to the store and buy some more, 99 bottles of milk on the wall. ``` -## 💡Pistas: +## 💡 Pistas: + Al final de la canción, la letra cambia porque es solo una botella (singular en lugar del plural). -+ Lee la última parte de la letra y verás como cambia la última línea a `"go to the store and by some more"`. \ No newline at end of file ++ Lee la última parte de la letra y verás como cambia la última línea a `"Go to the store and buy some more, 99 bottles of milk on the wall."`. diff --git a/exercises/19-Bottles-Of-Milk/README.md b/exercises/19-Bottles-Of-Milk/README.md index ef5f2704..ce4d00c1 100644 --- a/exercises/19-Bottles-Of-Milk/README.md +++ b/exercises/19-Bottles-Of-Milk/README.md @@ -14,11 +14,11 @@ Here you can listen to the song: https://www.youtube.com/watch?v=Xy-da43E6Lo 2. The function needs to **print** (use the `print` statement and not `return`) the exact same lyrics in the song. -## Expected result: +## 💻 Expected result: The result should be something like this: -```sh +```text 99 bottles of milk on the wall, 99 bottles of milk. Take one down and pass it around, 98 bottles of milk on the wall. @@ -36,8 +36,8 @@ No more bottles of milk on the wall, no more bottles of milk. Go to the store and buy some more, 99 bottles of milk on the wall. ``` -## 💡Hints: +## 💡 Hints: -+ At the end of the song, the lyrics change because it is only **one** bottle (singular instead of plural). ++ At the end of the song, the lyrics change because there is only **one** bottle (singular instead of plural). -+ Read the last lyrics and you will see how the last line changes to `"go to the store and buy some more"`. \ No newline at end of file ++ Read the last lyrics, and you will see how the last line changes to `"Go to the store and buy some more, 99 bottles of milk on the wall."`. diff --git a/exercises/19-Bottles-Of-Milk/app.py b/exercises/19-Bottles-Of-Milk/app.py index 9ff11964..9733b0fc 100644 --- a/exercises/19-Bottles-Of-Milk/app.py +++ b/exercises/19-Bottles-Of-Milk/app.py @@ -1 +1 @@ -# ✅↓ Write your code here. ↓✅ +# ✅↓ Write your code here ↓✅ diff --git a/exercises/19-Bottles-Of-Milk/solution.hide.py b/exercises/19-Bottles-Of-Milk/solution.hide.py index 52000ba9..658f18fc 100644 --- a/exercises/19-Bottles-Of-Milk/solution.hide.py +++ b/exercises/19-Bottles-Of-Milk/solution.hide.py @@ -1,4 +1,4 @@ -# ✅↓ Write your code here. ↓✅ +# ✅↓ Write your code here ↓✅ def number_of_bottles(): for x in range(99,2,-1): print(str(x) + " bottles of milk on the wall, " + str(x) + " bottles of milk. Take one down and pass it around, " + str(x-1)+ " bottles of milk on the wall.") @@ -7,4 +7,4 @@ def number_of_bottles(): print("No more bottles of milk on the wall, no more bottles of milk. Go to the store and buy some more, 99 bottles of milk on the wall.") return None -number_of_bottles() \ No newline at end of file +number_of_bottles() diff --git a/exercises/19-Bottles-Of-Milk/test.py b/exercises/19-Bottles-Of-Milk/test.py index 86f8ff9d..70af0ca9 100644 --- a/exercises/19-Bottles-Of-Milk/test.py +++ b/exercises/19-Bottles-Of-Milk/test.py @@ -25,7 +25,7 @@ def test_function_spin_chamber(capsys, app): regex = r"number_of_bottles\(\)" assert re.match(regex, content[my_printCallVar]) -@pytest.mark.it('The function must return the expected output') +@pytest.mark.it('The function must print the expected output') def test_for_function_output(capsys): number_of_bottles() captured = capsys.readouterr()