Skip to content

exercises 009-two_digits to 016-century #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 63 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
63aa235
Update README.md
josemoracard Dec 12, 2023
146c10d
Update README.es.md
josemoracard Dec 12, 2023
7432f92
Update app.py
josemoracard Dec 12, 2023
f158225
Update app.py
josemoracard Dec 12, 2023
7cf3426
Update solution.hide.py
josemoracard Dec 12, 2023
ab98d4c
Update solution.hide.py
josemoracard Dec 12, 2023
25caead
Update README.md
josemoracard Dec 12, 2023
ec5455e
Update README.es.md
josemoracard Dec 12, 2023
e8bbb82
Update test.py
josemoracard Dec 12, 2023
e6b0686
Update README.md
josemoracard Dec 12, 2023
7540b8b
Update app.py
josemoracard Dec 12, 2023
d15a5ed
Update solution.hide.py
josemoracard Dec 12, 2023
0620a38
Update test.py
josemoracard Dec 12, 2023
e58fb49
Update README.es.md
josemoracard Dec 12, 2023
1289d45
Update README.md
josemoracard Dec 12, 2023
13a7177
Update README.es.md
josemoracard Dec 12, 2023
2095335
Update app.py
josemoracard Dec 12, 2023
f4d06cd
Update solution.hide.py
josemoracard Dec 12, 2023
750e68d
Update test.py
josemoracard Dec 12, 2023
e933227
Update README.md
josemoracard Dec 12, 2023
4056581
Update README.md
josemoracard Dec 12, 2023
6e20ab5
Update README.es.md
josemoracard Dec 12, 2023
5f3a05d
Update README.es.md
josemoracard Dec 12, 2023
61c53eb
Update README.md
josemoracard Dec 12, 2023
b4f7ef1
Update README.md
josemoracard Dec 12, 2023
3e4c53d
Update README.md
josemoracard Dec 12, 2023
ce0deba
Update README.es.md
josemoracard Dec 12, 2023
37380cc
Update README.es.md
josemoracard Dec 12, 2023
bc8f68f
Update app.py
josemoracard Dec 12, 2023
20360fb
Update solution.hide.py
josemoracard Dec 12, 2023
c6c37b9
Update test.py
josemoracard Dec 12, 2023
10b8d88
Update solution.hide.py
josemoracard Dec 12, 2023
0c019c1
Update solution.hide.py
josemoracard Dec 12, 2023
c18d528
Update README.md
josemoracard Dec 12, 2023
53ac90c
Update README.es.md
josemoracard Dec 12, 2023
523768c
Update app.py
josemoracard Dec 12, 2023
4faba1a
Update solution.hide.py
josemoracard Dec 12, 2023
66eeb43
Update test.py
josemoracard Dec 12, 2023
30c7906
Update README.md
josemoracard Dec 12, 2023
0e57b0d
Update README.es.md
josemoracard Dec 12, 2023
94244bb
Update app.py
josemoracard Dec 12, 2023
7285b76
Update solution.hide.py
josemoracard Dec 12, 2023
b4a2069
Update test.py
josemoracard Dec 12, 2023
2adc375
Update README.md
josemoracard Dec 13, 2023
0cfa61f
Update README.md
josemoracard Dec 13, 2023
1f60e25
Update README.es.md
josemoracard Dec 13, 2023
d65b9df
Update README.md
josemoracard Dec 13, 2023
163cc91
Update README.es.md
josemoracard Dec 13, 2023
5a059c4
Update README.md
josemoracard Dec 13, 2023
c315c3a
Update README.es.md
josemoracard Dec 13, 2023
f50f10d
Update app.py
josemoracard Dec 13, 2023
bfef736
Update solution.hide.py
josemoracard Dec 13, 2023
72182ca
Update test.py
josemoracard Dec 13, 2023
60842b1
Update README.md
josemoracard Dec 13, 2023
c9a575d
Update README.es.md
josemoracard Dec 13, 2023
00747ed
Update README.es.md
josemoracard Dec 13, 2023
f07dbf8
Update README.md
josemoracard Dec 13, 2023
3ed937c
Update README.md
josemoracard Dec 13, 2023
299aa8d
Update README.es.md
josemoracard Dec 13, 2023
d4f6745
Update app.py
josemoracard Dec 13, 2023
5cf180a
Update solution.hide.py
josemoracard Dec 13, 2023
db4ea9e
Update solution.hide.py
josemoracard Dec 13, 2023
2d3bde6
Update test.py
josemoracard Dec 13, 2023
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
16 changes: 8 additions & 8 deletions exercises/009-two_digits/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

## 📝 Instrucciones:

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.
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).

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

```py
two_digits(79)
```

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

+ (7, 9)

## 💡 Pistas:
```py
(7, 9)
```

+ 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/
## 💡 Pista:

+ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
+ 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.
16 changes: 8 additions & 8 deletions exercises/009-two_digits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

## 📝 Instructions:

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.
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).

## Example input:
## 📎 Example input:

```py
two_digits(79)
```

## Example output:
## 📎 Example output:

+ (7, 9)

## 💡 Hints:
```py
(7, 9)
```

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

+ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
+ Use the operator of integer division `//` to obtain the tens digit and the operator of remainder `%` to obtain the ones digit.
8 changes: 4 additions & 4 deletions exercises/009-two_digits/app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#Complete the function to return the tens digit and the ones digit of any interger.
def two_digits(digit):
# Complete the function to return the tens digit and the units digit of any interger
def two_digits(number):
# Your code here
return None



#Invoke the function with any interger as its argument.
# Invoke the function with any two digit integer as its argument
print(two_digits(79))
23 changes: 17 additions & 6 deletions exercises/009-two_digits/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#Complete the function to return the tens digit and the ones digit of any interger.
def two_digits(digit):
aux = str(digit)
return (int(aux[0]), int(aux[1]))
# Complete the function to return the tens digit and the units digit of any interger
def two_digits(number):
# Your code here
aux = str(number)
return (int(aux[0]), int(aux[1]))



#Invoke the function with any interger as its argument.
# Invoke the function with any two digit integer as its argument
print(two_digits(79))


### SOLUTION 2 ###

# def two_digits(number):
# tens_digit = number // 10
# ones_digit = number % 10

# return tens_digit, ones_digit

# print(two_digits(37))
2 changes: 1 addition & 1 deletion exercises/009-two_digits/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_for_file_output(capsys, app):
def test_for_file_output(capsys, app):
assert app.two_digits(30) == (3,0)

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

Expand Down
6 changes: 3 additions & 3 deletions exercises/010-swap_digits/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

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.

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

```py
swap_digits(79)
```

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

```py
97
```

## 💡 Pistas:

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

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

Expand Down
9 changes: 5 additions & 4 deletions exercises/010-swap_digits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@

## 📝 Instructions:

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

## Example input:
## 📎 Example input:

```py
swap_digits(79)
```

## Example output:
## 📎 Example output:

```py
97
```

## 💡 Hints:

+ 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 the theory for this lesson: https://snakify.org/lessons/integer_float_numbers/

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

Expand Down
4 changes: 2 additions & 2 deletions exercises/010-swap_digits/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#Complete the fuction to return the swapped digits of a given two-digit-interger.
# Complete the function to return the swapped digits of a given two-digit integer
def swap_digits(num):
# Your code here
return None

#Invoke the function with any two digit interger as its argument
# Invoke the function with any two-digit integer as its argument
print(swap_digits(30))
8 changes: 3 additions & 5 deletions exercises/010-swap_digits/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#Complete the fuction to return the swapped digits of a given two-digit-interger.
# Complete the function to return the swapped digits of a given two-digit integer
def swap_digits(num):
# Your code here
aux = str(num)[1] +str(num)[0]

aux = str(num)[1] + str(num)[0]
return int(aux)


#Invoke the function with any two digit interger as its argument
# Invoke the function with any two-digit integer as its argument
print(swap_digits(30))
4 changes: 2 additions & 2 deletions exercises/010-swap_digits/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def test_return_exists():
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')
@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')
@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
9 changes: 5 additions & 4 deletions exercises/011-last_two_digits/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,22 @@

## 📝 Instrucciones:

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

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

```py
last_two_digits(1234)
```

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

```py
34
```

## 💡 Pistas:

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

+ 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 trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/
8 changes: 4 additions & 4 deletions exercises/011-last_two_digits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

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

## Example input:
## 📎 Example input:

```py
last_two_digits(1234)
```

## Example output:
## 📎 Example output:

```py
34
```

## 💡 Hints:

+ 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 the 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 may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/
4 changes: 2 additions & 2 deletions exercises/011-last_two_digits/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Complete the function to print the last two digits of an interger greater than 9.
# Complete the function to print the last two digits of an integer greater than 9
def last_two_digits(num):
return None

#Invoke the function with any interger greater than 9.
# Invoke the function with any integer greater than 9
print(last_two_digits())
7 changes: 3 additions & 4 deletions exercises/011-last_two_digits/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#Complete the function to print the last two digits of an interger greater than 9.
# Complete the function to print the last two digits of an integer greater than 9
def last_two_digits(num):
if num > 9: return int(str(num)[-2:])
else: return num


#Invoke the function with any interger greater than 9.
print(last_two_digits(1222))
# Invoke the function with any integer greater than 9
print(last_two_digits(212))
2 changes: 1 addition & 1 deletion exercises/011-last_two_digits/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_for_return(capsys, app):
def test_for_output_type(capsys, app):
assert type(app.last_two_digits(30)) == type(1)

@pytest.mark.it('The function last_two_digits must return only the last 2 digits of a integer greater than 9')
@pytest.mark.it('The function last_two_digits must return only the last 2 digits of an integer greater than 9')
def test_for_file_output(capsys, app):
if app.last_two_digits(30) > 9:
assert app.last_two_digits(30) == int(str(30)[-2:])
Expand Down
22 changes: 6 additions & 16 deletions exercises/012-tens_digit/README.es.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,18 @@

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

## Ejemplo de entrada 1:
## 📎 Ejemplo 1:

```py
tens_digit(1234)
output = tens_digit(1234)
print(output) # 3
```

## Ejemplo de salida 1:
## 📎 Ejemplo 2:

```py
3
```

## Ejemplo de entrada 2:

```py
tens_digit(179)
```

## Ejemplo de salida 2:

```py
7
output = tens_digit(179)
print(output) # 7
```

## 💡 Pistas:
Expand Down
24 changes: 7 additions & 17 deletions exercises/012-tens_digit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,22 @@

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

## Example input 1:
## 📎 Example 1:

```py
tens_digit(1234)
output = tens_digit(1234)
print(output) # 3
```

## Example output 1:
## 📎 Example 2:

```py
3
```

## Example input 2:

```py
tens_digit(179)
```

## Example output 2:

```py
7
output = tens_digit(179)
print(output) # 7
```

## 💡 Hints:

+ 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 the 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/
8 changes: 3 additions & 5 deletions exercises/012-tens_digit/app.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#Complete the function to return the tens digit of a given interger
# Complete the function to return the tens digit of a given integer
def tens_digit(num):
return None




#Invoke the function with any interger.
print(tens_digit())
# Invoke the function with any integer
print(tens_digit())
8 changes: 3 additions & 5 deletions exercises/012-tens_digit/solution.hide.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#Complete the function to return the tens digit of a given interger
# Complete the function to return the tens digit of a given integer
def tens_digit(num):
return (num // 10) % 10




#Invoke the function with any interger.
print(tens_digit(123))
# Invoke the function with any integer
print(tens_digit(198))
2 changes: 1 addition & 1 deletion exercises/012-tens_digit/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_for_return(capsys, app):
def test_for_output_type(capsys, app):
assert type(app.tens_digit(123)) == type(1)

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

Expand Down
Loading