Skip to content

Commit 5fccba7

Browse files
Merge pull request #40 from kiddopro/01-10
01 10
2 parents 6aca24e + f572bce commit 5fccba7

File tree

27 files changed

+219
-32
lines changed

27 files changed

+219
-32
lines changed

exercises/001-hello_world/README.es.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ Cada idioma tiene funciones para integrarse con la consola, ya que al principio
66

77
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.
88

9+
## 📝 Instrucciones:
10+
11+
1. Usa la función `print()` para escribir `"Hello World"` en la consola. Siéntete libre de intentar otras cosas también.
12+
913
## Ejemplo:
1014

1115
```py
1216
print("How are you?")
1317
```
1418

15-
## 📝 Instrucciones:
16-
17-
1. Usa la función `print()` para escribir `"Hello World"` en la consola. Siéntete libre de intentar otras cosas también.
18-
1919
## 💡 Pista:
2020

2121
+ Video de 5 minutos sobre [la consola](https://www.youtube.com/watch?v=vROGBvX_MHQ)

exercises/001-hello_world/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ Every language has a console, as it was the only way to interact with the users
66

77
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.
88

9+
## 📝 Instructions:
10+
11+
1. Use the `print()` function to print `"Hello World"` on the console. Feel free to try other things as well.
12+
913
## Example:
1014

1115
```py
1216
print("How are you?")
1317
```
1418

15-
## 📝 Instructions:
16-
17-
1. Use the `print()` function to print `"Hello World"` on the console. Feel free to try other things as well.
18-
1919
## 💡 Hint:
2020

2121
+ 5 minutes video about [the console](https://www.youtube.com/watch?v=1RlkftxAo-M)

exercises/002-sum_of_three_numbers/README.es.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
## Ejemplo de entrada:
88

9-
+ 2
10-
+ 3
11-
+ 6
9+
```py
10+
2
11+
3
12+
6
13+
```
1214

1315
## Ejemplo de salida:
1416

15-
+ 11
17+
```py
18+
11
19+
```
1620

exercises/002-sum_of_three_numbers/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66

77
## Example input:
88

9-
+ 2
10-
+ 3
11-
+ 6
9+
```py
10+
2
11+
3
12+
6
13+
```
1214

1315
## Example output:
1416

15-
+ 11
17+
```py
18+
11
19+
```
1620

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Complete the function to return the area of the triangle.
2+
def area_of_triangle(arg1, arg2):
3+
#your code here, please remove the "None"
4+
return arg1 * arg2 / 2
5+
6+
# Testing your function
7+
print(area_of_triangle(3, 5))

exercises/003-area_of_right_triangle/test.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import io, sys, os, pytest, json, mock
22
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
33

4-
54
@pytest.mark.it('The function area_of_triangle should exist')
6-
def test_function_exists(capsys):
5+
def test_function_exists(capsys, app):
76
try:
8-
import app
97
app.area_of_triangle
108
except AttributeError:
119
raise AttributeError("The function 'area_of_triangle' should exist on app.py")
1210

11+
@pytest.mark.it('The function must return something')
12+
def test_function_returns(capsys, app):
13+
result = app.area_of_triangle(1, 2)
14+
assert result != None
15+
16+
@pytest.mark.it('The function must return a number')
17+
def test_function_return_type(capsys, app):
18+
result = app.area_of_triangle(1,2)
19+
assert type(result) == type(1*2/2)
20+
1321
@pytest.mark.it('The solution should return the expected output. Testing with 3 and 5')
1422
def test_convert_inputs(capsys, app):
1523
result = app.area_of_triangle(3, 5)
1624
assert result == 7.5
1725

18-
@pytest.mark.it('The solution should return the expected output. Testing with 4 and 6')
19-
def test_convert_inputs(capsys, app):
20-
result = app.area_of_triangle(4, 6)
21-
assert result == 12
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Complete the function below to print the output per the example.
2+
def hello_name(name):
3+
4+
return "Hello, "+name+"!"
5+
6+
#Invoke the function with your name as the function's argument.
7+
print(hello_name("Bob"))

exercises/004-hello_harry/test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
def test_for_functon_existence(capsys, app):
55
assert callable(app.hello_name)
66

7+
@pytest.mark.it('The function must return something')
8+
def test_function_return(capsys, app):
9+
result = app.hello_name('test')
10+
assert result != None
11+
12+
@pytest.mark.it('The function must return a string')
13+
def test_function_return_type(capsys, app):
14+
result = app.hello_name('test')
15+
assert type(result) == type('')
16+
717
@pytest.mark.it('The function hello_name must accept 1 parameter and return the correct output')
818
def test_for_file_output(capsys, app):
919
assert app.hello_name('a') == "Hello, a!"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#Complete the function to return the previous and next number of a given numner.".
2+
def previous_next(num):
3+
return (num-1, num+1)
4+
5+
6+
#Invoke the function with any interger at its argument.
7+
print(previous_next(179))

exercises/005-previous_and_next/test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
def test_for_functon_existence(capsys, app):
55
assert callable(app.previous_next)
66

7+
@pytest.mark.it('The function must return something')
8+
def test_function_return(capsys, app):
9+
assert app.previous_next(6) != None
10+
11+
@pytest.mark.it('The function return a tuple')
12+
def test_function_return_type(capsys, app):
13+
result = app.previous_next(6)
14+
assert type(result) == type((1,2))
15+
716
@pytest.mark.it('The function previous_next must return the correct output')
817
def test_for_file_output(capsys, app):
918
assert app.previous_next(6) == (5, 7)

0 commit comments

Comments
 (0)