diff --git a/exercises/001-hello_world/README.es.md b/exercises/001-hello_world/README.es.md index 2c9587be..ed5394e9 100644 --- a/exercises/001-hello_world/README.es.md +++ b/exercises/001-hello_world/README.es.md @@ -6,16 +6,16 @@ Cada idioma tiene funciones para integrarse con la consola, ya que al principio Hoy en d铆a, la impresi贸n en la consola se utiliza sobre todo como herramienta de monitoreo, ideal para dejar un rastro del contenido de las variables durante la ejecuci贸n del programa. +## 馃摑 Instrucciones: + +1. Usa la funci贸n `print()` para escribir `"Hello World"` en la consola. Si茅ntete libre de intentar otras cosas tambi茅n. + ## Ejemplo: ```py print("How are you?") ``` -## 馃摑 Instrucciones: - -1. Usa la funci贸n `print()` para escribir `"Hello World"` en la consola. Si茅ntete libre de intentar otras cosas tambi茅n. - ## 馃挕 Pista: + Video de 5 minutos sobre [la consola](https://www.youtube.com/watch?v=vROGBvX_MHQ) diff --git a/exercises/001-hello_world/README.md b/exercises/001-hello_world/README.md index 759cd90c..6617e61d 100644 --- a/exercises/001-hello_world/README.md +++ b/exercises/001-hello_world/README.md @@ -6,16 +6,16 @@ Every language has a console, as it was the only way to interact with the users Today, printing in the console is used mostly as a monitoring tool, ideal to leave a trace of the content of variables during the program execution. +## 馃摑 Instructions: + +1. Use the `print()` function to print `"Hello World"` on the console. Feel free to try other things as well. + ## Example: ```py print("How are you?") ``` -## 馃摑 Instructions: - -1. Use the `print()` function to print `"Hello World"` on the console. Feel free to try other things as well. - ## 馃挕 Hint: + 5 minutes video about [the console](https://www.youtube.com/watch?v=1RlkftxAo-M) \ No newline at end of file diff --git a/exercises/002-sum_of_three_numbers/README.es.md b/exercises/002-sum_of_three_numbers/README.es.md index e9940523..cbff4ae3 100644 --- a/exercises/002-sum_of_three_numbers/README.es.md +++ b/exercises/002-sum_of_three_numbers/README.es.md @@ -6,11 +6,15 @@ ## Ejemplo de entrada: -+ 2 -+ 3 -+ 6 +```py +2 +3 +6 +``` ## Ejemplo de salida: -+ 11 +```py +11 +``` diff --git a/exercises/002-sum_of_three_numbers/README.md b/exercises/002-sum_of_three_numbers/README.md index a20c2a61..86b03520 100644 --- a/exercises/002-sum_of_three_numbers/README.md +++ b/exercises/002-sum_of_three_numbers/README.md @@ -6,11 +6,15 @@ ## Example input: -+ 2 -+ 3 -+ 6 +```py +2 +3 +6 +``` ##聽Example output: -+ 11 +```py +11 +``` diff --git a/exercises/003-area_of_right_triangle/solution.hide.py b/exercises/003-area_of_right_triangle/solution.hide.py new file mode 100644 index 00000000..58d34297 --- /dev/null +++ b/exercises/003-area_of_right_triangle/solution.hide.py @@ -0,0 +1,7 @@ +#Complete the function to return the area of the triangle. +def area_of_triangle(arg1, arg2): + #your code here, please remove the "None" + return arg1 * arg2 / 2 + +# Testing your function +print(area_of_triangle(3, 5)) \ No newline at end of file diff --git a/exercises/003-area_of_right_triangle/test.py b/exercises/003-area_of_right_triangle/test.py index 2bd1909d..6c7ed02b 100644 --- a/exercises/003-area_of_right_triangle/test.py +++ b/exercises/003-area_of_right_triangle/test.py @@ -1,21 +1,25 @@ import io, sys, os, pytest, json, mock path = os.path.dirname(os.path.abspath(__file__))+'/app.py' - @pytest.mark.it('The function area_of_triangle should exist') -def test_function_exists(capsys): +def test_function_exists(capsys, app): try: - import app app.area_of_triangle except AttributeError: raise AttributeError("The function 'area_of_triangle' should exist on app.py") +@pytest.mark.it('The function must return something') +def test_function_returns(capsys, app): + result = app.area_of_triangle(1, 2) + assert result != None + +@pytest.mark.it('The function must return a number') +def test_function_return_type(capsys, app): + result = app.area_of_triangle(1,2) + assert type(result) == type(1*2/2) + @pytest.mark.it('The solution should return the expected output. Testing with 3 and 5') def test_convert_inputs(capsys, app): result = app.area_of_triangle(3, 5) assert result == 7.5 -@pytest.mark.it('The solution should return the expected output. Testing with 4 and 6') -def test_convert_inputs(capsys, app): - result = app.area_of_triangle(4, 6) - assert result == 12 diff --git a/exercises/004-hello_harry/solution.hide.py b/exercises/004-hello_harry/solution.hide.py new file mode 100644 index 00000000..8e7c0e41 --- /dev/null +++ b/exercises/004-hello_harry/solution.hide.py @@ -0,0 +1,7 @@ +#Complete the function below to print the output per the example. +def hello_name(name): + + return "Hello, "+name+"!" + +#Invoke the function with your name as the function's argument. +print(hello_name("Bob")) diff --git a/exercises/004-hello_harry/test.py b/exercises/004-hello_harry/test.py index e669f8c7..3a988e84 100644 --- a/exercises/004-hello_harry/test.py +++ b/exercises/004-hello_harry/test.py @@ -4,6 +4,16 @@ def test_for_functon_existence(capsys, app): assert callable(app.hello_name) +@pytest.mark.it('The function must return something') +def test_function_return(capsys, app): + result = app.hello_name('test') + assert result != None + +@pytest.mark.it('The function must return a string') +def test_function_return_type(capsys, app): + result = app.hello_name('test') + assert type(result) == type('') + @pytest.mark.it('The function hello_name must accept 1 parameter and return the correct output') def test_for_file_output(capsys, app): assert app.hello_name('a') == "Hello, a!" \ No newline at end of file diff --git a/exercises/005-previous_and_next/solution.hide.py b/exercises/005-previous_and_next/solution.hide.py new file mode 100644 index 00000000..4280c6e7 --- /dev/null +++ b/exercises/005-previous_and_next/solution.hide.py @@ -0,0 +1,7 @@ +#Complete the function to return the previous and next number of a given numner.". +def previous_next(num): + return (num-1, num+1) + + +#Invoke the function with any interger at its argument. +print(previous_next(179)) \ No newline at end of file diff --git a/exercises/005-previous_and_next/test.py b/exercises/005-previous_and_next/test.py index 877708a1..a953748d 100644 --- a/exercises/005-previous_and_next/test.py +++ b/exercises/005-previous_and_next/test.py @@ -4,6 +4,15 @@ def test_for_functon_existence(capsys, app): assert callable(app.previous_next) +@pytest.mark.it('The function must return something') +def test_function_return(capsys, app): + assert app.previous_next(6) != None + +@pytest.mark.it('The function return a tuple') +def test_function_return_type(capsys, app): + result = app.previous_next(6) + assert type(result) == type((1,2)) + @pytest.mark.it('The function previous_next must return the correct output') def test_for_file_output(capsys, app): assert app.previous_next(6) == (5, 7) diff --git a/exercises/006-apple_sharing/README.es.md b/exercises/006-apple_sharing/README.es.md index cac76b43..1905f10f 100644 --- a/exercises/006-apple_sharing/README.es.md +++ b/exercises/006-apple_sharing/README.es.md @@ -1,4 +1,4 @@ -# `007` apple sharing +# `006` apple sharing ## 馃摑 Instrucciones: diff --git a/exercises/006-apple_sharing/README.md b/exercises/006-apple_sharing/README.md index e7121d89..cbde1805 100644 --- a/exercises/006-apple_sharing/README.md +++ b/exercises/006-apple_sharing/README.md @@ -1,4 +1,4 @@ -# `007` apple sharing +# `006` apple sharing ## 馃摑 Instructions: diff --git a/exercises/006-apple_sharing/solution.hide.py b/exercises/006-apple_sharing/solution.hide.py new file mode 100644 index 00000000..6cccd262 --- /dev/null +++ b/exercises/006-apple_sharing/solution.hide.py @@ -0,0 +1,12 @@ +#Complete the function to return: +#1) How many apples each single student will get. +#2) How many apples wil remain in the basket. +#Hint: You can resolve this exercise either importing the math module or without it +def apple_sharing(n,k): + + return (round(k/n),k%n) + + + +#Print the two answer per the example output. +print(apple_sharing(6,50)) \ No newline at end of file diff --git a/exercises/006-apple_sharing/test.py b/exercises/006-apple_sharing/test.py index ad4798bd..378851f4 100644 --- a/exercises/006-apple_sharing/test.py +++ b/exercises/006-apple_sharing/test.py @@ -4,6 +4,15 @@ def test_for_functon_existence(capsys, app): assert callable(app.apple_sharing) +@pytest.mark.it('The function must return something') +def test_function_return(capsys, app): + assert app.apple_sharing(10, 54) != None + +@pytest.mark.it('The function must return a tuple') +def test_function_return_type(capsys, app): + result = app.apple_sharing(10, 54) + assert type(result) == type((1,2)) + @pytest.mark.it('The function apple_sharing must return the correct output') def test_for_file_output(capsys, app): assert app.apple_sharing(10, 54) == (54//10, 54%10) diff --git a/exercises/006.1-square_value_of_number/README.es.md b/exercises/006.1-square_value_of_number/README.es.md index 7316cd10..4555fe4b 100644 --- a/exercises/006.1-square_value_of_number/README.es.md +++ b/exercises/006.1-square_value_of_number/README.es.md @@ -4,6 +4,17 @@ 1. Escribe una funci贸n llamada `square()` que calcule el valor al cuadrado de un n煤mero +## Ejemplo de entrada: + +```py +square(6) +``` + +## Ejemplo de salida: + +```py +36 +``` ## 馃挕 Pista: + Usa el operador `**`. diff --git a/exercises/006.1-square_value_of_number/README.md b/exercises/006.1-square_value_of_number/README.md index 3c850748..8e89d0bf 100644 --- a/exercises/006.1-square_value_of_number/README.md +++ b/exercises/006.1-square_value_of_number/README.md @@ -4,6 +4,18 @@ 1. Write a function called `square()` that calculates the square value of a number. +## Example input: + +```py +square(6) +``` + +## Example output: + +```py +36 +``` + ## 馃挕 Hint: + Using the `**` operator diff --git a/exercises/006.1-square_value_of_number/app.py b/exercises/006.1-square_value_of_number/app.py index cfdfa83d..42d75244 100644 --- a/exercises/006.1-square_value_of_number/app.py +++ b/exercises/006.1-square_value_of_number/app.py @@ -1 +1,5 @@ # your code here +def square(num): + return None + +print(square(6)) \ No newline at end of file diff --git a/exercises/006.1-square_value_of_number/test.py b/exercises/006.1-square_value_of_number/test.py index 8873922f..8bb35b61 100644 --- a/exercises/006.1-square_value_of_number/test.py +++ b/exercises/006.1-square_value_of_number/test.py @@ -4,11 +4,20 @@ def test_for_functon_existence(capsys, app): assert callable(app.square) -@pytest.mark.it('The we tried 6 and it should return 36') +@pytest.mark.it('The function must return something') +def test_function_return(capsys, app): + assert app.square(2) != None + +@pytest.mark.it('The function must return a number') +def test_function_return_type(capsys, app): + result = app.square(6) + assert type(result) == type(1) + +@pytest.mark.it('The function should return the square of the given number.') def test_for_file_output(capsys, app): assert app.square(6) == 6*6 -@pytest.mark.it('The we tried 47 and it should return 2209') +@pytest.mark.it('The function should return the square of the given number. Testing with 47.') def test_for_file_output(capsys, app): assert app.square(47) == 47*47 diff --git a/exercises/007-hours_and_minutes/test.py b/exercises/007-hours_and_minutes/test.py index 02d07e1c..c04651f8 100644 --- a/exercises/007-hours_and_minutes/test.py +++ b/exercises/007-hours_and_minutes/test.py @@ -4,6 +4,20 @@ def test_for_functon_existence(capsys, app): assert callable(app.hours_minutes) +@pytest.mark.it('The function must return something') +def test_function_return(capsys, app): + assert app.hours_minutes(60) != None + +@pytest.mark.it('The function must return a tuple') +def test_function_return_type(capsys, app): + result = app.hours_minutes(60) + assert type(result) == type((1,2)) + +@pytest.mark.it('The function must return a tuple with numbers') +def test_for_file_output(capsys, app): + result = app.hours_minutes(60) + assert type(result[0]) == type(1) and type(result[1]) == type(1) + @pytest.mark.it('The function hours_minutes must return the correct output for 60 secs') def test_for_file_output(capsys, app): assert app.hours_minutes(60) == (0, 1) diff --git a/exercises/008-two_timestamps/solution.hide.py b/exercises/008-two_timestamps/solution.hide.py new file mode 100644 index 00000000..9c81eba9 --- /dev/null +++ b/exercises/008-two_timestamps/solution.hide.py @@ -0,0 +1,14 @@ +#Complete the funtion to compute how many seconds passed between the two timestamp. +def two_timestamp(hr1,min1,sec1,hr2,min2,sec2): + fisrt_hour = hr1 * 3600 + first_min = min1 * 60 + final_first = fisrt_hour + first_min + sec1 + second_hour = hr2 * 3600 + second_min = min2 * 60 + final_second = second_hour + second_min + sec2 + + return final_second - final_first + + +#Invoke the fuction and pass two timestamps(6 intergers) as its argument. +print(two_timestamp(1,1,1,2,2,2)) \ No newline at end of file diff --git a/exercises/008-two_timestamps/test.py b/exercises/008-two_timestamps/test.py index 1c9f5321..43b4dd62 100644 --- a/exercises/008-two_timestamps/test.py +++ b/exercises/008-two_timestamps/test.py @@ -4,6 +4,16 @@ def test_for_functon_existence(capsys, app): assert callable(app.two_timestamp) +@pytest.mark.it('The function must return something') +def test_function_return(capsys, app): + result = app.two_timestamp(1,2,30,4,3,20) + assert result != None + +@pytest.mark.it('The function must return a number') +def test_function_return_type(capsys, app): + result = app.two_timestamp(1,2,30,4,3,20) + assert type(result) == type(1) + @pytest.mark.it('We tried passing (1,2,30,4,3,20) as parameters and the function did not return 10850. Keep Trying!') def test_for_file_output(capsys, app): assert app.two_timestamp(1,2,30,4,3,20) == ( (3 * 60) + (4 * 3600) + 20 )- ((2 * 60) + (1 * 3600) + 30) diff --git a/exercises/009-two_digits/solution.hide.py b/exercises/009-two_digits/solution.hide.py new file mode 100644 index 00000000..8fdb1e2e --- /dev/null +++ b/exercises/009-two_digits/solution.hide.py @@ -0,0 +1,9 @@ +#Complete the function to return the tens digit and the ones digit of any interger. +def two_digits(digit): + aux = str(digit) + return (int(aux[0]), int(aux[1])) + + + +#Invoke the function with any interger as its argument. +print(two_digits(79)) diff --git a/exercises/009-two_digits/test.py b/exercises/009-two_digits/test.py index 549e7c0e..d75ab637 100644 --- a/exercises/009-two_digits/test.py +++ b/exercises/009-two_digits/test.py @@ -4,9 +4,27 @@ def test_for_functon_existence(capsys, app): assert callable(app.two_digits) +@pytest.mark.it('The function must return something') +def test_function_return(capsys, app): + assert app.two_digits(30) != None + +@pytest.mark.it('The function must return a tuple') +def test_function_return_type(capsys, app): + result = app.two_digits(30) + assert type(result) == type((1,2)) + +@pytest.mark.it('The function must return a tuple with numbers') +def test_for_file_output(capsys, app): + result = app.two_digits(30) + assert type(result[0]) == type(1) and type(result[1]) == type(1) + @pytest.mark.it('The function two_digits must return the left and right digits of a 2 digits integer') def test_for_file_output(capsys, app): - assert app.two_digits(30) == (30//10, 30%10) + assert app.two_digits(30) == (3,0) + +@pytest.mark.it('The function two_digits must return the left and right digits of a 2 digits integer. Testing with 45.') +def test_for_file_output(capsys, app): + assert app.two_digits(45) == (4,5) diff --git a/exercises/010-swap_digits/README.es.md b/exercises/010-swap_digits/README.es.md index 3f2c5c84..c2d66a2a 100644 --- a/exercises/010-swap_digits/README.es.md +++ b/exercises/010-swap_digits/README.es.md @@ -12,7 +12,9 @@ swap_digits(79) ## Ejemplo de salida: -+ 97 +```py +97 +``` ## 馃挕 Pistas: diff --git a/exercises/010-swap_digits/README.md b/exercises/010-swap_digits/README.md index fe97fdfa..ac829f0a 100644 --- a/exercises/010-swap_digits/README.md +++ b/exercises/010-swap_digits/README.md @@ -12,8 +12,9 @@ swap_digits(79) ## Example output: -+ 97 - +```py +97 +``` ## 馃挕 Hints: + 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/ diff --git a/exercises/010-swap_digits/app.py b/exercises/010-swap_digits/app.py index d60c443c..0024a1bd 100644 --- a/exercises/010-swap_digits/app.py +++ b/exercises/010-swap_digits/app.py @@ -1,7 +1,7 @@ #Complete the fuction to return the swapped digits of a given two-digit-interger. def swap_digits(num): # Your code here - + return None #Invoke the function with any two digit interger as its argument print(swap_digits(30)) diff --git a/exercises/010-swap_digits/solution.hide.py b/exercises/010-swap_digits/solution.hide.py new file mode 100644 index 00000000..35324ddd --- /dev/null +++ b/exercises/010-swap_digits/solution.hide.py @@ -0,0 +1,10 @@ +#Complete the fuction to return the swapped digits of a given two-digit-interger. +def swap_digits(num): + # Your code here + aux = str(num)[1] +str(num)[0] + + return int(aux) + + +#Invoke the function with any two digit interger as its argument +print(swap_digits(30))