Skip to content

Commit a9a79d9

Browse files
authored
Merge pull request 4GeeksAcademy#58 from josemoracard/jose7-28-sequence-of-lines
exercises 28-sequence-of-lines to 34-a-aa-aaa-aaaa
2 parents dfbfb9b + 7bc11bf commit a9a79d9

File tree

33 files changed

+325
-124
lines changed

33 files changed

+325
-124
lines changed
Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
# `28` Sequence of lines
22

3-
Escribe un programa que acepte una secuencia de líneas como entrada y que luego imprima las líneas convirtiendo todos los caracteres en mayúscula.
3+
## 📝 Instrucciones:
44

5-
Supongamos le entregamos la siguiente entrada al programa:
6-
Hello world
7-
Practice makes perfect
8-
El resultado debería ser este:
9-
HELLO WORLD
10-
PRACTICE MAKES PERFECT
5+
1. Escribe la función `lines()`. Dado un string, haz que la función retorne todos los caracteres del string en mayúsculas.
116

12-
Pistas:
13-
En caso de que se le pasen entradas de datos a la pregunta, deben asumirse como entradas de la consola.
7+
## 📎 Ejemplo de entrada:
8+
9+
```py
10+
lines("Hello world, practice makes perfect")
11+
```
12+
13+
## 📎 Ejemplo de salida:
14+
15+
```text
16+
HELLO WORLD, PRACTICE MAKES PERFECT
17+
```
18+
19+
## 💡 Pista:
20+
21+
+ Googlea cómo convertir un string a mayúsculas en Python.
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
# `28` Sequence of lines
22

3-
Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized.
4-
Suppose the following input is supplied to the program:
5-
Hello world
6-
Practice makes perfect
7-
Then, the output should be:
8-
HELLO WORLD
9-
PRACTICE MAKES PERFECT
10-
11-
Hints:
12-
In case of input data being supplied to the question, it should be assumed to be a console input.
13-
14-
Solution:
3+
## 📝 Instructions:
4+
5+
1. Write a function `lines()`. Given a string, make the function return all the characters from the string capitalized.
6+
7+
## 📎 Example input:
8+
9+
```py
10+
lines("Hello world, practice makes perfect")
11+
```
12+
13+
## 📎 Example output:
14+
15+
```text
16+
HELLO WORLD, PRACTICE MAKES PERFECT
17+
```
18+
19+
## 💡 Hint:
20+
21+
+ Google how to capitalize a string in Python.

exercises/28-sequence-of-lines/app.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Your code here
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1+
# Your code here
12
def lines(text):
23
return text.upper()
34

4-
print(lines('Hello world'))
5+
print(lines('Hello world, practice makes perfect'))

exercises/28-sequence-of-lines/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ def test_function_existence(capsys, app):
99
def test_expected_output(capsys, app):
1010
assert app.lines("hello world") == "HELLO WORLD"
1111

12-
@pytest.mark.it('The function should return the expected output')
12+
@pytest.mark.it('The function should return the expected output. Testing with a different value')
1313
def test_another_output(capsys, app):
1414
assert app.lines("LeT the WOrld know YoU") == "LET THE WORLD KNOW YOU"
Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1-
# `29`Eliminar los duplicados
1+
# `29` Remove duplicate words
22

3-
Escribe un programa que acepte una secuencia de palabras separadas por espacios en blanco como entrada y que imprima luego las palabras eliminando todas las duplicadas y ordenándolas alfanuméricamente.
3+
## 📝 Instrucciones:
44

5-
Supongamos que se le entrega la siguiente entrada al programa:
5+
1. Escribe la función `remove_duplicate_words()` que tome una secuencia de palabras separadas por espacios en blanco como entrada. Luego, retorna las palabras eliminando duplicados y organizándolas alfanuméricamente.
66

7-
hello world and practice makes perfect and hello world again
7+
## 📎 Ejemplo de entrada:
88

9-
El resultado debería ser:
9+
```py
10+
remove_duplicate_words("hello world and practice makes perfect and hello world again")
11+
```
1012

11-
again and hello makes perfect practice world
13+
## 📎 Ejemplo de salida:
1214

13-
Pistas:
14-
En caso de que se le entregue entradas de datos a la pregunta, debe asumirse como entrada de la consola.
15+
```text
16+
again and hello makes perfect practice world
17+
```
1518

16-
Usa set container para eliminar los datos duplicados automáticamente y luego usa sorted() para ordenar los datos.
19+
## 💡 Pistas:
1720

21+
+ Puedes convertir tu entrada en el tipo de dato `set` para eliminar automáticamente cualquier duplicado.
1822

23+
+ Puedes utilizar `sorted()` para ordenar los elementos de una lista.
Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
# `29` Remove duplicate words
22

3-
Write a program that accepts a sequence of whitespace separated words as input and prints the words after removing all duplicate words and sorting them alphanumerically.
4-
Suppose the following input is supplied to the program:
5-
hello world and practice makes perfect and hello world again
6-
Then, the output should be:
3+
## 📝 Instructions:
4+
5+
1. Write a function called `remove_duplicate_words()` that accepts a sequence of whitespace separated words as input and returns the words after removing all duplicate words and sorting them alphanumerically.
6+
7+
## 📎 Example input:
8+
9+
```py
10+
remove_duplicate_words("hello world and practice makes perfect and hello world again")
11+
```
12+
13+
## 📎 Example output:
14+
15+
```text
716
again and hello makes perfect practice world
17+
```
18+
19+
## 💡 Hints:
820

9-
Hints:
10-
In case of input data being supplied to the question, it should be assumed to be a console input.
11-
We use set container to remove duplicated data automatically and then use sorted() to sort the data.
21+
+ You can convert your input into the `set` data type to automatically eliminate duplicates.
1222

23+
+ You can use `sorted()` to sort the data from a list.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
s = input()
2-
words = [word for word in s.split(" ")]
3-
print (" ".join(sorted(list(set(words)))))
1+
# Your code here
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Your code here
12
def remove_duplicate_words(text):
23
words = text.split()
34
return (" ".join(sorted(list(set(words)))))
5+
6+
print(remove_duplicate_words("hello world and practice makes perfect and hello world again"))

exercises/29-remove-duplicate-words/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ def test_function_existence(capsys, app):
88
def test_expected_output(capsys, app):
99
assert app.remove_duplicate_words("hello world and practice makes perfect and hello world again") == "again and hello makes perfect practice world"
1010

11-
@pytest.mark.it('The function should work with other entries')
11+
@pytest.mark.it('The function should work with other entries. Testing with different values')
1212
def test_expected_output_2(capsys, app):
1313
assert app.remove_duplicate_words("lets try this again with another try") == "again another lets this try with"
1414

15-
@pytest.mark.it('The function should work with other entries')
15+
@pytest.mark.it('The function should work with other entries. Testing with different values')
1616
def test_expected_output_3(capsys, app):
1717
assert app.remove_duplicate_words("Jacke was Named Jacke by his mother") == "Jacke Named by his mother was"
1818

0 commit comments

Comments
 (0)