Skip to content
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
2 changes: 1 addition & 1 deletion exercises/10-Two_digits/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ def two_digits(digit):


#Invoke the function with any interger as its argument.
print(two_digits())
print(two_digits(79))
24 changes: 15 additions & 9 deletions exercises/11-Swap_digits/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@

## 📝 Instrucciones:

1. Dado un entero de dos dígitos, intercambia sus dígitos de posición e imprime el resultado.
1. Crea una función llamada `swap_digits()` dado un número entero de dos dígitos, intercambia sus dígitos de posición e imprime el resultado.

### Ejemplo de entrada:
## Ejemplo de entrada:

+ 79
```
swap_digits(79)
```

### Ejemplo de salida:
## Ejemplo de salida:

+ 97
```
97
```

## 💡 Pista:

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

+ También puedes intentar paso a paso con trozos de la teoría:
https://snakify.org/lessons/integer_float_numbers/steps/1/
+ También puedes intentar paso a paso con parte de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/

+ Ten en cuenta que para concatenar dos números puedes transformar su valor en un string con str(num).

+ El valor a retornar debe ser un número entero.
24 changes: 15 additions & 9 deletions exercises/11-Swap_digits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@

## 📝 Instructions:

1. Given a two-digit integer, swap its digits and print the result.
1. Create a function named `swap_digits()` given a two-digit integer, swap its digits and print the result.

##Example input:
## Example input:

+ 79
```py
swap_digits(79)
```

##Example output:
## Example output:

+ 97
```
97
```

## 💡 Hint:

+ 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/
+ 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/

+ You may also try step-by-step theory chunks:
https://snakify.org/lessons/integer_float_numbers/steps/1/
+ You can also try step-by-step with theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/

+ Note that you need to concatenate two numbers, so you may have to convert them into a string `str(number)`.

+ The function must return a number.
8 changes: 3 additions & 5 deletions exercises/11-Swap_digits/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#Complete the fuction to return the swapped digits of a given two-digit-interger.
def swap_digits(num):
return None


# Your code here


#Invoke the function with any two digit interger as its argument
print(swap_digits())

print(swap_digits(30))
23 changes: 16 additions & 7 deletions exercises/11-Swap_digits/test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
import io, sys, pytest, os, re, mock
import io, sys, pytest, os, re, mock, app

@pytest.mark.it('The function swap_digits must exist')
def test_for_functon_existence(capsys, app):
assert callable(app.swap_digits)

@pytest.mark.it('The function swap_digits must swap the digits of a 2 digits integer')
def test_for_file_output(capsys, app):
assert app.swap_digits(30) == str(30%10)+str(30//10)
def test_function_exists():
assert app.swap_digits

@pytest.mark.it('The function swap_digits must return something')
def test_return_exists():
assert app.swap_digits(12) != None

@pytest.mark.it('The function swap_digits should return an integer')
def test_return_integer():
assert type(app.swap_digits(23)) == type(1)

@pytest.mark.it('The function `swap_digits` must swap the digits. Testing with 79')
def test_for_file_output(capsys, app):
assert app.swap_digits(79) == 97

@pytest.mark.it('The function `swap_digits` must swap the digits. Testing with 30')
def test_for_file_output_2(capsys, app):
assert app.swap_digits(30) == 3