Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5b6aa9b

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

File tree

40 files changed

+186
-190
lines changed

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 twodigit 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 twodigit 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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /