Skip to content

Commit 7672979

Browse files
committed
added some hints and tests
1 parent afb55bc commit 7672979

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#Complete the fuction to return the swapped digits of a given two-digit-interger.
2+
def swap_digits(num):
3+
return None
4+
5+
6+
7+
#Invoke the function with any two digit interger as its argument
8+
print(swap_digits())
9+
10+

exercises/11-Swap_digits/README.es.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@
88

99
+ 79
1010

11+
+ 30
12+
1113
### Ejemplo de salida:
1214

1315
+ 97
1416

17+
+ 3
18+
1519
## 💡 Pista:
1620

1721
+ Si no sabes cómo empezar la solución a esta asignación, por favor, revisa la teoría en esta lección:
1822
https://snakify.org/lessons/integer_float_numbers/
1923

2024
+ También puedes intentar paso a paso con trozos de la teoría:
21-
https://snakify.org/lessons/integer_float_numbers/steps/1/
25+
https://snakify.org/lessons/integer_float_numbers/steps/1/
26+
27+
+ Ten en cuenta que para concatenar dos números puedes transformar su valor en un string con str(num).
28+
29+
+ El valor a retornar debe ser un número entero.

exercises/11-Swap_digits/README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,22 @@
88

99
+ 79
1010

11+
+ 30
12+
1113
### Example output:
1214

1315
+ 97
1416

17+
+ 3
18+
1519
## 💡 Hint:
1620

1721
+ If you don't know how to start solving this assignment, please, review a theory for this lesson:
1822
https://snakify.org/lessons/integer_float_numbers/
1923

2024
+ You may also try step-by-step theory chunks:
21-
https://snakify.org/lessons/integer_float_numbers/steps/1/
25+
https://snakify.org/lessons/integer_float_numbers/steps/1/
26+
27+
+ Note that you need to concatenate two numbers, so in order not to add those values you may have to convert them as a string (str)
28+
29+
+ The function must return a number

exercises/11-Swap_digits/test.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,33 @@
44
def test_for_functon_existence(capsys, app):
55
assert callable(app.swap_digits)
66

7+
# @pytest.mark.it('The function swap_digits must return something')
8+
# def test_for_functon_return_statement(capsys, app):
9+
# path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
10+
# with open(path, 'r') as content_file:
11+
# content = content_file.read()
12+
# regex = re.compile(r"return(\s*)([^a-zA-Z0-9_])\w+")
13+
# assert bool(regex.search(content)) == True
14+
15+
716
@pytest.mark.it('The function swap_digits must swap the digits of a 2 digits integer')
817
def test_for_file_output(capsys, app):
9-
assert app.swap_digits(30) == int(30%10)+int(30//10)
18+
result = str(30%10)+str(30//10)
19+
assert app.swap_digits(30) == int(result)
20+
21+
22+
# @pytest.mark.it('The function swap_digits(30) shoud return 3 as an integer')
23+
# def test_for_file_output(capsys, app):
24+
# assert app.swap_digits(30) == 3
25+
1026

27+
# @pytest.mark.it('The function swap_digits(30) shoud return 3 as an integer')
28+
# def test_for_file_output(capsys, app):
29+
# assert app.swap_digits(79) == 97
1130

1231

32+
# @pytest.mark.it('The function swap_digits(25) shoud return 52 as an integer')
33+
# def test_for_file_output(capsys, app):
34+
# assert app.swap_digits(35) == 53
35+
1336

0 commit comments

Comments
 (0)