Skip to content

01 10 #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions exercises/001-hello_world/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
8 changes: 4 additions & 4 deletions exercises/001-hello_world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 8 additions & 4 deletions exercises/002-sum_of_three_numbers/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

## Ejemplo de entrada:

+ 2
+ 3
+ 6
```py
2
3
6
```

## Ejemplo de salida:

+ 11
```py
11
```

12 changes: 8 additions & 4 deletions exercises/002-sum_of_three_numbers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

## Example input:

+ 2
+ 3
+ 6
```py
2
3
6
```

## Example output:

+ 11
```py
11
```

7 changes: 7 additions & 0 deletions exercises/003-area_of_right_triangle/solution.hide.py
Original file line number Diff line number Diff line change
@@ -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))
18 changes: 11 additions & 7 deletions exercises/003-area_of_right_triangle/test.py
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions exercises/004-hello_harry/solution.hide.py
Original file line number Diff line number Diff line change
@@ -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"))
10 changes: 10 additions & 0 deletions exercises/004-hello_harry/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
7 changes: 7 additions & 0 deletions exercises/005-previous_and_next/solution.hide.py
Original file line number Diff line number Diff line change
@@ -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))
9 changes: 9 additions & 0 deletions exercises/005-previous_and_next/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion exercises/006-apple_sharing/README.es.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `007` apple sharing
# `006` apple sharing

## 📝 Instrucciones:

Expand Down
2 changes: 1 addition & 1 deletion exercises/006-apple_sharing/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `007` apple sharing
# `006` apple sharing

## 📝 Instructions:

Expand Down
12 changes: 12 additions & 0 deletions exercises/006-apple_sharing/solution.hide.py
Original file line number Diff line number Diff line change
@@ -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))
9 changes: 9 additions & 0 deletions exercises/006-apple_sharing/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions exercises/006.1-square_value_of_number/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `**`.
12 changes: 12 additions & 0 deletions exercises/006.1-square_value_of_number/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions exercises/006.1-square_value_of_number/app.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# your code here
def square(num):
return None

print(square(6))
13 changes: 11 additions & 2 deletions exercises/006.1-square_value_of_number/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions exercises/007-hours_and_minutes/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 14 additions & 0 deletions exercises/008-two_timestamps/solution.hide.py
Original file line number Diff line number Diff line change
@@ -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))
10 changes: 10 additions & 0 deletions exercises/008-two_timestamps/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions exercises/009-two_digits/solution.hide.py
Original file line number Diff line number Diff line change
@@ -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))
20 changes: 19 additions & 1 deletion exercises/009-two_digits/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)



Expand Down
4 changes: 3 additions & 1 deletion exercises/010-swap_digits/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ swap_digits(79)

## Ejemplo de salida:

+ 97
```py
97
```

## 💡 Pistas:

Expand Down
Loading