Skip to content

Commit 5b6aa9b

Browse files
authored
Merge pull request #54 from josemoracard/jose4-009-two_digits
exercises 009-two_digits to 016-century
2 parents d8777d7 + 2d3bde6 commit 5b6aa9b

40 files changed

+186
-190
lines changed

exercises/009-two_digits/README.es.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
## 📝 Instrucciones:
44

5-
1. Crea una función llamada `two_digits()`. Dado un entero de dos dígitos,`two_digits()` devuelve su dígito izquierdo (las decenas) y luego su dígito derecho (las unidades). Utiliza el operador de división de enteros para obtener el dígito de las decenas y el operador de residuo/resto para obtener el dígito de las unidades.
5+
1. Crea una función llamada `two_digits()`. Dado un entero de dos dígitos, `two_digits()` devuelve su dígito izquierdo (las decenas) y luego su dígito derecho (las unidades).
66

7-
## Ejemplo de entrada:
7+
## 📎 Ejemplo de entrada:
88

99
```py
1010
two_digits(79)
1111
```
1212

13-
## Ejemplo de salida:
13+
## 📎 Ejemplo de salida:
1414

15-
+ (7, 9)
16-
17-
## 💡 Pistas:
15+
```py
16+
(7, 9)
17+
```
1818

19-
+ Si no sabes por donde partir este ejercicio, por favor revisa la teoría en esta lección: https://snakify.org/lessons/integer_float_numbers/
19+
## 💡 Pista:
2020

21-
+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
21+
+ Utiliza el operador de división de enteros `//` para obtener el dígito de las decenas y el operador de resto `%` para obtener el dígito de las unidades.

exercises/009-two_digits/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
## 📝 Instructions:
44

5-
1. Create a function named `two_digits()`. Given a two-digit integer, `two_digits()` returns its left digit (a tens digit) and then its right digit (a ones digit). Use the operator of integer division to obtain the tens digit and the operator of taking remainder to obtain the ones digit.
5+
1. Create a function named `two_digits()`. Given a two-digit integer, `two_digits()` returns its left digit (the tens digit) and then its right digit (the units digit).
66

7-
## Example input:
7+
## 📎 Example input:
88

99
```py
1010
two_digits(79)
1111
```
1212

13-
## Example output:
13+
## 📎 Example output:
1414

15-
+ (7, 9)
16-
17-
## 💡 Hints:
15+
```py
16+
(7, 9)
17+
```
1818

19-
+ 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/
19+
## 💡 Hint:
2020

21-
+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
21+
+ Use the operator of integer division `//` to obtain the tens digit and the operator of remainder `%` to obtain the ones digit.

exercises/009-two_digits/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#Complete the function to return the tens digit and the ones digit of any interger.
2-
def two_digits(digit):
1+
# Complete the function to return the tens digit and the units digit of any interger
2+
def two_digits(number):
3+
# Your code here
34
return None
45

56

6-
7-
#Invoke the function with any interger as its argument.
7+
# Invoke the function with any two digit integer as its argument
88
print(two_digits(79))
Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1-
#Complete the function to return the tens digit and the ones digit of any interger.
2-
def two_digits(digit):
3-
aux = str(digit)
4-
return (int(aux[0]), int(aux[1]))
1+
# Complete the function to return the tens digit and the units digit of any interger
2+
def two_digits(number):
3+
# Your code here
4+
aux = str(number)
5+
return (int(aux[0]), int(aux[1]))
56

67

7-
8-
#Invoke the function with any interger as its argument.
8+
# Invoke the function with any two digit integer as its argument
99
print(two_digits(79))
10+
11+
12+
### SOLUTION 2 ###
13+
14+
# def two_digits(number):
15+
# tens_digit = number // 10
16+
# ones_digit = number % 10
17+
18+
# return tens_digit, ones_digit
19+
20+
# print(two_digits(37))

exercises/009-two_digits/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def test_for_file_output(capsys, app):
2222
def test_for_file_output(capsys, app):
2323
assert app.two_digits(30) == (3,0)
2424

25-
@pytest.mark.it('The function two_digits must return the left and right digits of a 2 digits integer. Testing with 45.')
25+
@pytest.mark.it('The function two_digits must return the left and right digits of a 2 digits integer. Testing with 45')
2626
def test_for_file_output(capsys, app):
2727
assert app.two_digits(45) == (4,5)
2828

exercises/010-swap_digits/README.es.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44

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

7-
## Ejemplo de entrada:
7+
## 📎 Ejemplo de entrada:
88

99
```py
1010
swap_digits(79)
1111
```
1212

13-
## Ejemplo de salida:
13+
## 📎 Ejemplo de salida:
1414

1515
```py
1616
97
1717
```
1818

1919
## 💡 Pistas:
2020

21-
+ Si no sabes por donde partir este ejercicio, por favor revisa la teoría en esta lección: https://snakify.org/lessons/integer_float_numbers/
21+
+ Si no sabes por donde empezar este ejercicio, por favor revisa la teoría en esta lección: https://snakify.org/lessons/integer_float_numbers/
2222

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

exercises/010-swap_digits/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,23 @@
22

33
## 📝 Instructions:
44

5-
1. Complete a function named `swap_digits()`. Given a two-digit integer, `swap_digits()` swap its digits and prints the result.
5+
1. Complete a function named `swap_digits()`. Given a two-digit integer, `swap_digits()` swaps its digits and print the result.
66

7-
## Example input:
7+
## 📎 Example input:
88

99
```py
1010
swap_digits(79)
1111
```
1212

13-
## Example output:
13+
## 📎 Example output:
1414

1515
```py
1616
97
1717
```
18+
1819
## 💡 Hints:
1920

20-
+ 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/
21+
+ If you don't know how to start solving this assignment, please review the theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
2122

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

exercises/010-swap_digits/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
#Complete the fuction to return the swapped digits of a given two-digit-interger.
1+
# Complete the function to return the swapped digits of a given two-digit integer
22
def swap_digits(num):
33
# Your code here
44
return None
55

6-
#Invoke the function with any two digit interger as its argument
6+
# Invoke the function with any two-digit integer as its argument
77
print(swap_digits(30))
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
#Complete the fuction to return the swapped digits of a given two-digit-interger.
1+
# Complete the function to return the swapped digits of a given two-digit integer
22
def swap_digits(num):
33
# Your code here
4-
aux = str(num)[1] +str(num)[0]
5-
4+
aux = str(num)[1] + str(num)[0]
65
return int(aux)
7-
86

9-
#Invoke the function with any two digit interger as its argument
7+
# Invoke the function with any two-digit integer as its argument
108
print(swap_digits(30))

exercises/010-swap_digits/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ def test_return_exists():
1212
def test_return_integer():
1313
assert type(app.swap_digits(23)) == type(1)
1414

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

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

exercises/011-last_two_digits/README.es.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
## 📝 Instrucciones:
44

5-
1. Completa la función `last_two_digits()` para que dado un número entero mayor que `9`, imprima sus últimos dos dígitos.
5+
1. Completa la función `last_two_digits()` para que, dado un número entero mayor que `9`, imprima sus últimos dos dígitos.
66

7-
## Ejemplo de entrada:
7+
## 📎 Ejemplo de entrada:
88

99
```py
1010
last_two_digits(1234)
1111
```
1212

13-
## Ejemplo de salida:
13+
## 📎 Ejemplo de salida:
1414

1515
```py
1616
34
1717
```
18+
1819
## 💡 Pistas:
1920

2021
+ Si no sabes por donde comenzar este ejercicio, por favor, revisa la teoría en esta lección: https://snakify.org/lessons/integer_float_numbers/
2122

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

exercises/011-last_two_digits/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44

55
1. Complete the `last_two_digits()` function. Given an integer greater than `9`, `last_two_digits()` prints its last two digits.
66

7-
## Example input:
7+
## 📎 Example input:
88

99
```py
1010
last_two_digits(1234)
1111
```
1212

13-
## Example output:
13+
## 📎 Example output:
1414

1515
```py
1616
34
1717
```
1818

1919
## 💡 Hints:
2020

21-
+ 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/
21+
+ If you don't know how to start solving this assignment, please review the theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
2222

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

exercises/011-last_two_digits/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Complete the function to print the last two digits of an interger greater than 9.
1+
# Complete the function to print the last two digits of an integer greater than 9
22
def last_two_digits(num):
33
return None
44

5-
#Invoke the function with any interger greater than 9.
5+
# Invoke the function with any integer greater than 9
66
print(last_two_digits())
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#Complete the function to print the last two digits of an interger greater than 9.
1+
# Complete the function to print the last two digits of an integer greater than 9
22
def last_two_digits(num):
33
if num > 9: return int(str(num)[-2:])
44
else: return num
5-
65

7-
#Invoke the function with any interger greater than 9.
8-
print(last_two_digits(1222))
6+
# Invoke the function with any integer greater than 9
7+
print(last_two_digits(212))

exercises/011-last_two_digits/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_for_return(capsys, app):
1212
def test_for_output_type(capsys, app):
1313
assert type(app.last_two_digits(30)) == type(1)
1414

15-
@pytest.mark.it('The function last_two_digits must return only the last 2 digits of a integer greater than 9')
15+
@pytest.mark.it('The function last_two_digits must return only the last 2 digits of an integer greater than 9')
1616
def test_for_file_output(capsys, app):
1717
if app.last_two_digits(30) > 9:
1818
assert app.last_two_digits(30) == int(str(30)[-2:])

exercises/012-tens_digit/README.es.md

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,18 @@
44

55
1. Completa la función `tens_digit()` para que dado un número entero, retorne sus decenas.
66

7-
## Ejemplo de entrada 1:
7+
## 📎 Ejemplo 1:
88

99
```py
10-
tens_digit(1234)
10+
output = tens_digit(1234)
11+
print(output) # 3
1112
```
1213

13-
## Ejemplo de salida 1:
14+
## 📎 Ejemplo 2:
1415

1516
```py
16-
3
17-
```
18-
19-
## Ejemplo de entrada 2:
20-
21-
```py
22-
tens_digit(179)
23-
```
24-
25-
## Ejemplo de salida 2:
26-
27-
```py
28-
7
17+
output = tens_digit(179)
18+
print(output) # 7
2919
```
3020

3121
## 💡 Pistas:

exercises/012-tens_digit/README.md

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,22 @@
44

55
1. Complete the `tens_digit()` function. Given an integer, `tens_digit()` returns its tens digit.
66

7-
## Example input 1:
7+
## 📎 Example 1:
88

99
```py
10-
tens_digit(1234)
10+
output = tens_digit(1234)
11+
print(output) # 3
1112
```
1213

13-
## Example output 1:
14+
## 📎 Example 2:
1415

1516
```py
16-
3
17-
```
18-
19-
## Example input 2:
20-
21-
```py
22-
tens_digit(179)
23-
```
24-
25-
## Example output 2:
26-
27-
```py
28-
7
17+
output = tens_digit(179)
18+
print(output) # 7
2919
```
3020

3121
## 💡 Hints:
3222

33-
+ 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/
23+
+ If you don't know how to start solving this assignment, please review the theory for this lesson: https://snakify.org/lessons/integer_float_numbers/
3424

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

exercises/012-tens_digit/app.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#Complete the function to return the tens digit of a given interger
1+
# Complete the function to return the tens digit of a given integer
22
def tens_digit(num):
33
return None
44

55

6-
7-
8-
#Invoke the function with any interger.
9-
print(tens_digit())
6+
# Invoke the function with any integer
7+
print(tens_digit())
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
#Complete the function to return the tens digit of a given interger
1+
# Complete the function to return the tens digit of a given integer
22
def tens_digit(num):
33
return (num // 10) % 10
44

55

6-
7-
8-
#Invoke the function with any interger.
9-
print(tens_digit(123))
6+
# Invoke the function with any integer
7+
print(tens_digit(198))

exercises/012-tens_digit/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_for_return(capsys, app):
1212
def test_for_output_type(capsys, app):
1313
assert type(app.tens_digit(123)) == type(1)
1414

15-
@pytest.mark.it('We tried to pass 854345 as parameter and it did not return 4!')
15+
@pytest.mark.it('We tried to pass 854345 as parameter and it did not return 4')
1616
def test_for_file_output(capsys, app):
1717
assert app.tens_digit(854345) == (854345 // 10)%10
1818

0 commit comments

Comments
 (0)