File tree

15 files changed

+126
-11
lines changed

15 files changed

+126
-11
lines changed
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))
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_convert_inputs(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_convert_inputs(capsys, app):
18+
result = app.area_of_triangle(1, 2)
19+
assert type(result) == type(1)
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
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"))
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_convert_inputs(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_convert_inputs(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!"
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))
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_for_file_output(capsys, app):
9+
assert app.previous_next(6) != None
10+
11+
@pytest.mark.it('The function return a tuple')
12+
def test_for_file_output(capsys, app):
13+
result = app.previous_next(6)
14+
assert type(resul) == 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)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `007` apple sharing
1+
# `006` apple sharing
22

33
## 📝 Instrucciones:
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `007` apple sharing
1+
# `006` apple sharing
22

33
## 📝 Instructions:
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#Complete the function to return:
2+
#1) How many apples each single student will get.
3+
#2) How many apples wil remain in the basket.
4+
#Hint: You can resolve this exercise either importing the math module or without it
5+
def apple_sharing(n,k):
6+
7+
return (round(k/n),k%n)
8+
9+
10+
11+
#Print the two answer per the example output.
12+
print(apple_sharing(6,50))
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44
def test_for_functon_existence(capsys, app):
55
assert callable(app.apple_sharing)
66

7+
@pytest.mark.it('The function must return something')
8+
def test_for_file_output(capsys, app):
9+
assert app.apple_sharing(10, 54) != None
10+
11+
@pytest.mark.it('The function must return a tuple')
12+
def test_for_file_output(capsys, app):
13+
result = app.apple_sharing(10, 54)
14+
assert type(result) == type((1,2))
15+
716
@pytest.mark.it('The function apple_sharing must return the correct output')
817
def test_for_file_output(capsys, app):
918
assert app.apple_sharing(10, 54) == (54//10, 54%10)
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44

55
1. Escribe una función llamada `square()` que calcule el valor al cuadrado de un número
66

7+
## Ejemplo de entrada:
8+
9+
```py
10+
square(6)
11+
```
12+
13+
## Ejemplo de salida:
14+
15+
```py
16+
36
17+
```
718
## 💡 Pista:
819

920
+ Usa el operador `**`.
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44

55
1. Write a function called `square()` that calculates the square value of a number.
66

7+
## Example input:
8+
9+
```py
10+
square(6)
11+
```
12+
13+
## Example output:
14+
15+
```py
16+
36
17+
```
18+
719
## 💡 Hint:
820

921
+ Using the `**` operator
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
# your code here
2+
def square(num):
3+
return None
4+
5+
print(square(6))
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,20 @@
44
def test_for_functon_existence(capsys, app):
55
assert callable(app.square)
66

7-
@pytest.mark.it('The we tried 6 and it should return 36')
7+
@pytest.mark.it('The function must return something')
8+
def test_for_file_output(capsys, app):
9+
assert app.square(2) != None
10+
11+
@pytest.mark.it('The function must return a number')
12+
def test_for_file_output(capsys, app):
13+
result = app.square(6)
14+
assert type(result) == type(1)
15+
16+
@pytest.mark.it('The function should return the square of the given number.')
817
def test_for_file_output(capsys, app):
918
assert app.square(6) == 6*6
1019

11-
@pytest.mark.it('The we tried 47 and it should return 2209')
20+
@pytest.mark.it('The function should return the square of the given number. Testing with 47.')
1221
def test_for_file_output(capsys, app):
1322
assert app.square(47) == 47*47
1423

Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44
def test_for_functon_existence(capsys, app):
55
assert callable(app.hours_minutes)
66

7+
@pytest.mark.it('The function must return something')
8+
def test_for_file_output(capsys, app):
9+
assert app.hours_minutes(60) != None
10+
11+
@pytest.mark.it('The function must return a tuple')
12+
def test_for_file_output(capsys, app):
13+
result = app.hours_minutes(60)
14+
assert type(result) == type((1,2))
15+
16+
@pytest.mark.it('The function must return a tuple with numbers')
17+
def test_for_file_output(capsys, app):
18+
result = app.hours_minutes(60)
19+
assert type(result[0]) == type(1) and type(result[1]) == type(1)
20+
721
@pytest.mark.it('The function hours_minutes must return the correct output for 60 secs')
822
def test_for_file_output(capsys, app):
923
assert app.hours_minutes(60) == (0, 1)

0 commit comments

Comments
 (0)