-
Notifications
You must be signed in to change notification settings - Fork 171
exercises 28-sequence-of-lines to 34-a-aa-aaa-aaaa #58
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
alesanchezr
merged 65 commits into
4GeeksAcademy:master
from
josemoracard:jose7-28-sequence-of-lines
Jan 24, 2024
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
1cb917a
Update README.md
josemoracard 9f43e7b
Update README.md
josemoracard 1efb3fc
Update README.md
josemoracard 00c3fe6
Update README.md
josemoracard 089413c
Update README.es.md
josemoracard d516d24
Update app.py
josemoracard 13c5075
Update solution.hide.py
josemoracard 65d5808
Update test.py
josemoracard 26da269
Update README.md
josemoracard d6e0a42
Update README.md
josemoracard d0e5d1a
Update README.es.md
josemoracard 5ecc779
Update app.py
josemoracard 9a7ce14
Update solution.hide.py
josemoracard 5d821e4
Update test.py
josemoracard 7b8e1b4
Update README.md
josemoracard df0ab97
Update README.es.md
josemoracard f4b8bf4
Update README.md
josemoracard 138fbdb
Create README.es.md
josemoracard dffdf0a
Update app.py
josemoracard ffd37e3
Update solution.hide.py
josemoracard acd5aa2
Update solution.hide.py
josemoracard 2fcf548
Update test.py
josemoracard dd965a3
Update app.py
josemoracard 6ce1552
Update README.md
josemoracard 3edd0a9
Create README.es.md
josemoracard a995923
Update solution.hide.py
josemoracard e884a4a
Update README.md
josemoracard 77aa06b
Update README.md
josemoracard bf712bb
Create README.es.md
josemoracard 7012811
Update app.py
josemoracard fb8ae1d
Update solution.hide.py
josemoracard 15acd9a
Update test.py
josemoracard d8e1d6e
Update solution.hide.py
josemoracard 550fb6b
Update README.md
josemoracard 9a405ef
Update README.es.md
josemoracard 2ae5642
Update README.md
josemoracard 3dda56b
Update README.es.md
josemoracard d800b6d
Update README.md
josemoracard 5cd158c
Update app.py
josemoracard 250508f
Create README.es.md
josemoracard 6fa0295
Update solution.hide.py
josemoracard 12ee33e
Update README.md
josemoracard 7b9096b
Update README.es.md
josemoracard f975360
Update README.md
josemoracard 796164d
Update README.es.md
josemoracard 6dd5ebf
Update README.md
josemoracard b7c0e92
Update README.md
josemoracard a5c2f0b
Update README.md
josemoracard 0dbb207
Update app.py
josemoracard 90aad78
Update README.md
josemoracard acc046a
Update README.md
josemoracard 94bd26d
Create README.es.md
josemoracard 8e73ab0
Update solution.hide.py
josemoracard dcd7b76
Update test.py
josemoracard 796f82b
Update README.md
josemoracard a808b91
Update README.es.md
josemoracard 31dd906
Update README.md
josemoracard 655efe1
Update README.es.md
josemoracard f3097b4
Update README.md
josemoracard 7c3178a
Update README.es.md
josemoracard a7ecfcb
Update README.md
josemoracard 232ebfe
Update README.es.md
josemoracard 00f6e17
Update solution.hide.py
josemoracard 2275edf
Update README.es.md
josemoracard 7bc11bf
Update solution.hide.py
josemoracard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
# `28` Sequence of lines | ||
|
||
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. | ||
## 📝 Instrucciones: | ||
|
||
Supongamos le entregamos la siguiente entrada al programa: | ||
Hello world | ||
Practice makes perfect | ||
El resultado debería ser este: | ||
HELLO WORLD | ||
PRACTICE MAKES PERFECT | ||
1. Escribe la función `lines()`. Dado un string, haz que la función retorne todos los caracteres del string en mayúsculas. | ||
|
||
Pistas: | ||
En caso de que se le pasen entradas de datos a la pregunta, deben asumirse como entradas de la consola. | ||
## 📎 Ejemplo de entrada: | ||
|
||
```py | ||
lines("Hello world, practice makes perfect") | ||
``` | ||
|
||
## 📎 Ejemplo de salida: | ||
|
||
```text | ||
HELLO WORLD, PRACTICE MAKES PERFECT | ||
``` | ||
|
||
## 💡 Pista: | ||
|
||
+ Googlea cómo convertir un string a mayúsculas en Python. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,21 @@ | ||
# `28` Sequence of lines | ||
|
||
Write a program that accepts sequence of lines as input and prints the lines after making all characters in the sentence capitalized. | ||
Suppose the following input is supplied to the program: | ||
Hello world | ||
Practice makes perfect | ||
Then, the output should be: | ||
HELLO WORLD | ||
PRACTICE MAKES PERFECT | ||
|
||
Hints: | ||
In case of input data being supplied to the question, it should be assumed to be a console input. | ||
|
||
Solution: | ||
## 📝 Instructions: | ||
|
||
1. Write a function `lines()`. Given a string, make the function return all the characters from the string capitalized. | ||
|
||
## 📎 Example input: | ||
|
||
```py | ||
lines("Hello world, practice makes perfect") | ||
``` | ||
|
||
## 📎 Example output: | ||
|
||
```text | ||
HELLO WORLD, PRACTICE MAKES PERFECT | ||
``` | ||
|
||
## 💡 Hint: | ||
|
||
+ Google how to capitalize a string in Python. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Your code here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Your code here | ||
def lines(text): | ||
return text.upper() | ||
|
||
print(lines('Hello world')) | ||
print(lines('Hello world, practice makes perfect')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
# `29`Eliminar los duplicados | ||
# `29` Remove duplicate words | ||
|
||
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. | ||
## 📝 Instrucciones: | ||
|
||
Supongamos que se le entrega la siguiente entrada al programa: | ||
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. | ||
|
||
hello world and practice makes perfect and hello world again | ||
## 📎 Ejemplo de entrada: | ||
|
||
El resultado debería ser: | ||
```py | ||
remove_duplicate_words("hello world and practice makes perfect and hello world again") | ||
``` | ||
|
||
again and hello makes perfect practice world | ||
## 📎 Ejemplo de salida: | ||
|
||
Pistas: | ||
En caso de que se le entregue entradas de datos a la pregunta, debe asumirse como entrada de la consola. | ||
```text | ||
again and hello makes perfect practice world | ||
``` | ||
|
||
Usa set container para eliminar los datos duplicados automáticamente y luego usa sorted() para ordenar los datos. | ||
## 💡 Pistas: | ||
|
||
+ Puedes convertir tu entrada en el tipo de dato `set` para eliminar automáticamente cualquier duplicado. | ||
|
||
+ Puedes utilizar `sorted()` para ordenar los elementos de una lista. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
# `29` Remove duplicate words | ||
|
||
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. | ||
Suppose the following input is supplied to the program: | ||
hello world and practice makes perfect and hello world again | ||
Then, the output should be: | ||
## 📝 Instructions: | ||
|
||
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. | ||
|
||
## 📎 Example input: | ||
|
||
```py | ||
remove_duplicate_words("hello world and practice makes perfect and hello world again") | ||
``` | ||
|
||
## 📎 Example output: | ||
|
||
```text | ||
again and hello makes perfect practice world | ||
``` | ||
|
||
## 💡 Hints: | ||
|
||
Hints: | ||
In case of input data being supplied to the question, it should be assumed to be a console input. | ||
We use set container to remove duplicated data automatically and then use sorted() to sort the data. | ||
+ You can convert your input into the `set` data type to automatically eliminate duplicates. | ||
|
||
+ You can use `sorted()` to sort the data from a list. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
s = input() | ||
words = [word for word in s.split(" ")] | ||
print (" ".join(sorted(list(set(words))))) | ||
# Your code here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Your code here | ||
def remove_duplicate_words(text): | ||
words = text.split() | ||
return (" ".join(sorted(list(set(words))))) | ||
|
||
print(remove_duplicate_words("hello world and practice makes perfect and hello world again")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# `30` Divisable binary | ||
|
||
## 📝 Instrucciones: | ||
|
||
1. Escribe la función `divisible_binary()` que tome una secuencia de números binarios de 4 dígitos separados por comas como entrada y verifique si son divisibles por 5. Imprime los números que son divisibles por 5 en una secuencia separada por comas. | ||
|
||
## 📎 Ejemplo de entrada: | ||
|
||
```py | ||
divisible_binary("0100,0011,1010,1001") | ||
``` | ||
|
||
## 📎 Ejemplo de salida: | ||
|
||
```py | ||
1010 | ||
``` | ||
|
||
## 💡 Pista: | ||
|
||
+ Para convertir números binarios en nuestros números enteros cotidianos (base 10 o decimal), es necesario incluir la base del número que ingresamos en el primer argumento (en este caso, base 2 o binario), y la función `int()` se encargará del resto. Sería así: | ||
|
||
```py | ||
binary = '0101' | ||
decimal = int(binary, 2) | ||
|
||
print(decimal) # Output: 5 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,28 @@ | ||
Write a program which accepts a sequence of comma separated 4 digit binary numbers as its input and then check whether they are divisible by 5 or not. The numbers that are divisible by 5 are to be printed in a comma separated sequence. | ||
Example: | ||
0100,0011,1010,1001 | ||
Then the output should be: | ||
# `30` Divisable binary | ||
|
||
## 📝 Instructions: | ||
|
||
1. Write a function `divisible_binary()` that takes a sequence of comma-separated 4-digit binary numbers as input and checks if they are divisible by 5. Print the numbers that are divisible by 5 in a comma-separated sequence. | ||
|
||
## 📎 Example input: | ||
|
||
```py | ||
divisible_binary("0100,0011,1010,1001") | ||
``` | ||
|
||
## 📎 Example output: | ||
|
||
```py | ||
1010 | ||
Notes: Assume the data is input by console. | ||
``` | ||
|
||
## 💡 Hint: | ||
|
||
+ To convert binary numbers into our everyday integer numbers (base 10 or decimal), you have to include the base of the number we input in the first argument (in this case, base 2 or binary), and the function `int()` will take care of the rest. Like this: | ||
|
||
```py | ||
binary = '0101' | ||
decimal = int(binary, 2) | ||
|
||
Hints: | ||
In case of input data being supplied to the question, it should be assumed to be a console input. | ||
print(decimal) # Output: 5 | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Your code here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
def divisable_binary(text): | ||
value=[] | ||
items=[x for x in text.split(',')] | ||
for p in items: | ||
intp = int(p, 2) | ||
if not intp%5: | ||
value.append(p) | ||
# Your code here | ||
def divisible_binary(binary_sequence): | ||
divisible_numbers = [] | ||
binary_numbers = [x for x in binary_sequence.split(',')] | ||
for binary_num in binary_numbers: | ||
int_binary_num = int(binary_num, 2) | ||
if not int_binary_num % 5: | ||
divisible_numbers.append(binary_num) | ||
|
||
return (','.join(value)) | ||
return ','.join(divisible_numbers) | ||
|
||
print(divisible_binary("1000,1100,1010,1111")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import pytest, io, sys, json, mock, re, os | ||
|
||
@pytest.mark.it('The function divisable_binary must exist') | ||
@pytest.mark.it('The function divisible_binary must exist') | ||
def test_function_existence(capsys, app): | ||
assert app.divisable_binary | ||
assert app.divisible_binary | ||
|
||
@pytest.mark.it('The function should return the expected output') | ||
def test_expected_output(capsys, app): | ||
assert app.divisable_binary("0100,0011,1010,1001") == "1010" | ||
assert app.divisible_binary("0100,0011,1010,1001") == "1010" | ||
|
||
@pytest.mark.it('The function should work with other parameters. testing with 1111,1000,0101,0000') | ||
def test_expected_output_2(capsys, app): | ||
assert app.divisable_binary("1111,1000,0101,0000") == "1111,0101,0000" | ||
assert app.divisible_binary("1111,1000,0101,0000") == "1111,0101,0000" | ||
|
||
@pytest.mark.it("The function should work with other parameters. Testing with 1000") | ||
def test_expected_output_3(capsys, app): | ||
assert app.divisable_binary("1000,1000,1000,1000") == "" | ||
assert app.divisible_binary("1000,1000,1000,1000") == "" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# `31` All digits even | ||
|
||
## 📝 Instrucciones: | ||
|
||
1. Define una función llamada `all_digits_even()` para identificar e imprimir todos los números entre 1000 y 3000 (inclusive) en los que cada dígito es un número par. Muestra los números resultantes en una secuencia separada por comas en una sola línea. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
Write a program, which will find all such numbers between 1000 and 3000 (both included) such that each digit of the number is an even number. | ||
The numbers obtained should be printed in a comma-separated sequence on a single line. | ||
# `31` All digits even | ||
|
||
Hints: | ||
In case of input data being supplied to the question, it should be assumed to be a console input. | ||
## 📝 Instructions: | ||
|
||
Solution: | ||
1. Define a function named `all_digits_even()` to identify and print all numbers between 1000 and 3000 (inclusive) where each digit is an even number. Display the resulting numbers in a comma-separated sequence on a single line. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Your code here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
values = [] | ||
for i in range(1000, 3001): | ||
s = str(i) | ||
if (int(s[0])%2==0) and (int(s[1])%2==0) and (int(s[2])%2==0) and (int(s[3])%2==0): | ||
values.append(s) | ||
print ",".join(values) | ||
# Your code here | ||
def all_digits_even(): | ||
values = [] | ||
for i in range(1000, 3001): | ||
s = str(i) | ||
if (int(s[0]) % 2 == 0) and (int(s[1]) % 2 == 0) and (int(s[2]) % 2 == 0) and (int(s[3]) % 2 == 0): | ||
values.append(s) | ||
|
||
return ",".join(values) | ||
|
||
print(all_digits_even()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# `32` Number of letters and digits | ||
|
||
## 📝 Instrucciones: | ||
|
||
1. Escribe una función llamada `letters_and_digits()` que tome una oración como entrada y calcule la cantidad de letras y dígitos presentes en ella. | ||
|
||
## 📎 Ejemplo de entrada: | ||
|
||
```py | ||
letters_and_digits("hello world! 123") | ||
``` | ||
|
||
## 📎 Ejemplo de salida: | ||
|
||
```text | ||
LETTERS 10 | ||
DIGITS 3 | ||
``` | ||
|
||
## 💡 Pista: | ||
|
||
+ Declara un diccionario para guardar ambas cuentas en una sola variable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
Write a program that accepts a sentence and calculate the number of letters and digits. | ||
Suppose the following input is supplied to the program: | ||
hello world! 123 | ||
Then, the output should be: | ||
# `32` Number of letters and digits | ||
|
||
## 📝 Instructions: | ||
|
||
1. Write a function named `letters_and_digits()` that takes a sentence as input and calculates the number of letters and digits present in it. | ||
|
||
## 📎 Example input: | ||
|
||
```py | ||
letters_and_digits("hello world! 123") | ||
``` | ||
|
||
## 📎 Example output: | ||
|
||
```text | ||
LETTERS 10 | ||
DIGITS 3 | ||
``` | ||
|
||
## 💡 Hint: | ||
|
||
Hints: | ||
In case of input data being supplied to the question, it should be assumed to be a console input. | ||
+ Declare a dictionary for storing both counts in one variable. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Your code here |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incluye una breve explicacion de como transformar numeros binarios a numeros reales
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done