diff --git a/exercises/10-Two_digits/app.py b/exercises/10-Two_digits/app.py index d6b6011e..bb47dde0 100644 --- a/exercises/10-Two_digits/app.py +++ b/exercises/10-Two_digits/app.py @@ -5,4 +5,4 @@ def two_digits(digit): #Invoke the function with any interger as its argument. -print(two_digits()) +print(two_digits(79)) diff --git a/exercises/11-Swap_digits/README.es.md b/exercises/11-Swap_digits/README.es.md index 3da4d630..e20becb6 100644 --- a/exercises/11-Swap_digits/README.es.md +++ b/exercises/11-Swap_digits/README.es.md @@ -2,20 +2,26 @@ ## 馃摑 Instrucciones: -1. Dado un entero de dos d铆gitos, intercambia sus d铆gitos de posici贸n e imprime el resultado. +1. Crea una funci贸n llamada `swap_digits()` dado un n煤mero entero de dos d铆gitos, intercambia sus d铆gitos de posici贸n e imprime el resultado. -### Ejemplo de entrada: +## Ejemplo de entrada: -+ 79 +``` +swap_digits(79) +``` -### Ejemplo de salida: +## Ejemplo de salida: -+ 97 +``` +97 +``` ## 馃挕 Pista: -+ Si no sabes c贸mo empezar la soluci贸n a esta asignaci贸n, por favor, revisa la teor铆a en esta lecci贸n: -https://snakify.org/lessons/integer_float_numbers/ ++ Si no sabes c贸mo empezar la soluci贸n a esta asignaci贸n, por favor, revisa la teor铆a en esta lecci贸n: https://snakify.org/lessons/integer_float_numbers/ -+ Tambi茅n puedes intentar paso a paso con trozos de la teor铆a: -https://snakify.org/lessons/integer_float_numbers/steps/1/ \ No newline at end of file ++ Tambi茅n puedes intentar paso a paso con parte de la teor铆a: https://snakify.org/lessons/integer_float_numbers/steps/1/ + ++ Ten en cuenta que para concatenar dos n煤meros puedes transformar su valor en un string con str(num). + ++ El valor a retornar debe ser un n煤mero entero. diff --git a/exercises/11-Swap_digits/README.md b/exercises/11-Swap_digits/README.md index db5e824d..e63c9a90 100644 --- a/exercises/11-Swap_digits/README.md +++ b/exercises/11-Swap_digits/README.md @@ -2,20 +2,26 @@ ## 馃摑 Instructions: -1. Given a two-digit integer, swap its digits and print the result. +1. Create a function named `swap_digits()` given a two-digit integer, swap its digits and print the result. -###聽Example input: +## Example input: -+ 79 +```py +swap_digits(79) +``` -###聽Example output: +## Example output: -+ 97 +``` +97 +``` ## 馃挕 Hint: -+ If you don't know how to start solving this assignment, please, review a theory for this lesson: -https://snakify.org/lessons/integer_float_numbers/ ++ If you don't know how to start solving this assignment, please, review a theory for this lesson: https://snakify.org/lessons/integer_float_numbers/ -+ You may also try step-by-step theory chunks: -https://snakify.org/lessons/integer_float_numbers/steps/1/ \ No newline at end of file ++ You can also try step-by-step with theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/ + ++ Note that you need to concatenate two numbers, so you may have to convert them into a string `str(number)`. + ++ The function must return a number. diff --git a/exercises/11-Swap_digits/app.py b/exercises/11-Swap_digits/app.py index 697823fb..d60c443c 100644 --- a/exercises/11-Swap_digits/app.py +++ b/exercises/11-Swap_digits/app.py @@ -1,9 +1,7 @@ #Complete the fuction to return the swapped digits of a given two-digit-interger. def swap_digits(num): - return None - - + # Your code here + #Invoke the function with any two digit interger as its argument -print(swap_digits()) - +print(swap_digits(30)) diff --git a/exercises/11-Swap_digits/test.py b/exercises/11-Swap_digits/test.py index a0054654..9c9f61ab 100644 --- a/exercises/11-Swap_digits/test.py +++ b/exercises/11-Swap_digits/test.py @@ -1,12 +1,21 @@ -import io, sys, pytest, os, re, mock +import io, sys, pytest, os, re, mock, app @pytest.mark.it('The function swap_digits must exist') -def test_for_functon_existence(capsys, app): - assert callable(app.swap_digits) - -@pytest.mark.it('The function swap_digits must swap the digits of a 2 digits integer') -def test_for_file_output(capsys, app): - assert app.swap_digits(30) == str(30%10)+str(30//10) +def test_function_exists(): + assert app.swap_digits +@pytest.mark.it('The function swap_digits must return something') +def test_return_exists(): + assert app.swap_digits(12) != None +@pytest.mark.it('The function swap_digits should return an integer') +def test_return_integer(): + assert type(app.swap_digits(23)) == type(1) + +@pytest.mark.it('The function `swap_digits` must swap the digits. Testing with 79') +def test_for_file_output(capsys, app): + assert app.swap_digits(79) == 97 +@pytest.mark.it('The function `swap_digits` must swap the digits. Testing with 30') +def test_for_file_output_2(capsys, app): + assert app.swap_digits(30) == 3