diff --git a/exercises/017-total_cost/README.es.md b/exercises/017-total_cost/README.es.md index c130a7b4..51f4e5b5 100644 --- a/exercises/017-total_cost/README.es.md +++ b/exercises/017-total_cost/README.es.md @@ -2,20 +2,22 @@ ## 📝 Instrucciones: -1. Un cupcake (quequito) cuesta `D` dólares y `C` centavos. Escribe un función `total_cost()` para determinar cuántos dólares y centavos debería pagar una persona por `N` cupcakes. *La función recibe tres números: `D`, `C`, `N` y debería devolver dos números: costo total en dólares y los centavos* +1. Un cupcake cuesta `d` dólares y `c` centavos. Escribe una función `total_cost()` para determinar cuántos dólares y centavos debería pagar una persona por `n` cupcakes. *La función recibe tres números: `d`, `c`, `n` y debería devolver dos números: costo total en dólares y centavos* -## Ejemplo de entrada: +## 📎 Ejemplo de entrada: ```py total_cost(10,15,2) ``` -## Ejemplo de salida: +## 📎 Ejemplo de salida: -+ (20, 30) +```py +(20, 30) +``` ## 💡 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/ \ No newline at end of file ++ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/ diff --git a/exercises/017-total_cost/README.md b/exercises/017-total_cost/README.md index b3d00b6c..fe6f4040 100644 --- a/exercises/017-total_cost/README.md +++ b/exercises/017-total_cost/README.md @@ -2,20 +2,22 @@ ## 📝 Instructions: -1. A cupcake costs `D` dollars and `C` cents. Write a function that determines how many dollars and cents should someone pay for `N` cupcakes. *The function gets three numbers: `D`, `C`, `N` and it should return two numbers: total cost in dollars and cents.* +1. A cupcake costs `d` dollars and `c` cents. Write a function that determines how many dollars and cents someone should pay for `n` cupcakes. *The function gets three numbers: `d`, `c`, `n` and it should return two numbers: total cost in dollars and cents.* -## Example input: +## 📎 Example input: ```py total_cost(10,15,2) ``` -## Example output: +## 📎 Example output: -+ (20, 30) +```py +(20, 30) +``` ## 💡 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/ diff --git a/exercises/017-total_cost/app.py b/exercises/017-total_cost/app.py index acf6a4b1..cc578749 100644 --- a/exercises/017-total_cost/app.py +++ b/exercises/017-total_cost/app.py @@ -1,10 +1,7 @@ -#Complete the function to return the total cost in dollars and cents of N cupcakes. -#Remember you can return multiple parameters => return a, b -def total_cost(d,c,n): +# Complete the function to return the total cost in dollars and cents of (n) cupcakes +def total_cost(d, c, n): return None - - -#Invoke the function with three intergers: cost(dollars and cents) & number of cupcakes. -print(total_cost()) +# Invoke the function with three integers: total_cost(dollars, cents, number_of_cupcakes) +print(total_cost(15,22,4)) diff --git a/exercises/017-total_cost/solution.hide.py b/exercises/017-total_cost/solution.hide.py index 48763f08..dc6c33cf 100644 --- a/exercises/017-total_cost/solution.hide.py +++ b/exercises/017-total_cost/solution.hide.py @@ -1,10 +1,10 @@ -#Complete the function to return the total cost in dollars and cents of N cupcakes. -#Remember you can return multiple parameters => return a, b -def total_cost(d,c,n): - return ((((d*100)+c)*n)//100, (((d*100)+c)*n)%100) - +# Complete the function to return the total cost in dollars and cents of (n) cupcakes +def total_cost(d, c, n): + total_cents = (d * 100 + c) * n + total_dollars = total_cents // 100 + remaining_cents = total_cents % 100 + return total_dollars, remaining_cents - -#Invoke the function with three intergers: cost(dollars and cents) & number of cupcakes. +# Invoke the function with three integers: total_cost(dollars, cents, number_of_cupcakes) print(total_cost(15,22,4)) diff --git a/exercises/017-total_cost/test.py b/exercises/017-total_cost/test.py index db7473c1..ef3f1380 100644 --- a/exercises/017-total_cost/test.py +++ b/exercises/017-total_cost/test.py @@ -19,11 +19,11 @@ def test_function_return_type_parameters(capsys, app): result = app.total_cost(15, 22, 4) assert type(result[0]) == type(1) and type(result[1]) == type(1) -@pytest.mark.it('We tried to pass 15, 22, 4 as parameters and it did not return (60, 88)!') +@pytest.mark.it('We tried to pass 15, 22, 4 as parameters and it did not return (60, 88)') def test_for_file_output(capsys, app): assert app.total_cost(15, 22, 4) == (60, 88) -@pytest.mark.it('We tried to pass 10, 15, 4 as parameters and it did not return (20, 30)!') +@pytest.mark.it('We tried to pass 10, 15, 4 as parameters and it did not return (40, 60)') def test_for_file_output2(capsys, app): - assert app.total_cost(15, 22, 4) == (60, 88) + assert app.total_cost(10, 15, 4) == (40, 60) diff --git a/exercises/018-day_of_week/README.es.md b/exercises/018-day_of_week/README.es.md index ee27b49b..010cbccc 100644 --- a/exercises/018-day_of_week/README.es.md +++ b/exercises/018-day_of_week/README.es.md @@ -2,27 +2,31 @@ ## 📝 Instrucciones: -1. Escribe una función `day_of_week()`. Dado un entero `K` en el rango comprendido entre [1, 365], `day_of_week()` encuentra el número del día de la semana para el k-ésimo día del año si este año el 1 de enero fue jueves. +1. Escribe una función `day_of_week()`. Dado un entero `k` en el rango comprendido entre 1 a 365, `day_of_week()` encuentra el número del día de la semana para el k-ésimo día del año si este año el 1 de enero fue jueves. *Los días de la semana se enumeran así:* +```text 0 — Domingo 1 — Lunes 2 — Martes, ... -6 — Sábado. +6 — Sábado +``` -## Ejemplo de entrada: +## 📎 Ejemplo de entrada: ```py day_of_week(1) ``` -## Ejemplo de salida: +## 📎 Ejemplo de salida: -+ 4 +```py +4 +``` ## 💡 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/ \ No newline at end of file ++ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/ diff --git a/exercises/018-day_of_week/README.md b/exercises/018-day_of_week/README.md index e6efb15d..b3b5a9e2 100644 --- a/exercises/018-day_of_week/README.md +++ b/exercises/018-day_of_week/README.md @@ -2,27 +2,31 @@ ## 📝 Instructions: -1. Write a function `day_of_week()`. Given an integer `K` in the range 1 to 365 is given, `day_of_week()` finds the number of day of week for K-th day of year provided that in this year January 1 was Thursday. +1. Write a function `day_of_week()`. Given an integer `k` in the range 1 to 365, `day_of_week()` finds the number of day of week for *k-th* day of the year, provided that in this year January 1 was Thursday. -*Days of week are numbered as:* +*The days of the week are numbered as:* +```text 0 — Sunday 1 — Monday 2 — Tuesday, ... -6 — Saturday. +6 — Saturday +``` -## Example input: +## 📎 Example input: ```py day_of_week(1) ``` -## Example output: +## 📎 Example output: -+ 4 +```py +4 +``` ## 💡 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/ \ No newline at end of file ++ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/ diff --git a/exercises/018-day_of_week/app.py b/exercises/018-day_of_week/app.py index 866fcedc..110ad973 100644 --- a/exercises/018-day_of_week/app.py +++ b/exercises/018-day_of_week/app.py @@ -1,9 +1,7 @@ -#Complete the function to return the number of day of the week for k'th day of year. +# Complete the function to return the number of day of the week for k'th day of year def day_of_week(k): - return None - -#Invoke function day_of_week with an interger between 0 and 6 (number for days of week) -print(day_of_week()) \ No newline at end of file +# Invoke function day_of_week with an integer between 1 and 365 +print(day_of_week()) diff --git a/exercises/018-day_of_week/solution.hide.py b/exercises/018-day_of_week/solution.hide.py index d08fca75..c4acc7f3 100644 --- a/exercises/018-day_of_week/solution.hide.py +++ b/exercises/018-day_of_week/solution.hide.py @@ -1,9 +1,7 @@ -#Complete the function to return the number of day of the week for k'th day of year. +# Complete the function to return the number of day of the week for k'th day of year def day_of_week(k): - - return (3+k)%7 + return (3 + k) % 7 - -#Invoke function day_of_week with an interger between 0 and 6 (number for days of week) -print(day_of_week(1)) \ No newline at end of file +# Invoke function day_of_week with an integer between 1 and 365 +print(day_of_week(125)) diff --git a/exercises/018-day_of_week/test.py b/exercises/018-day_of_week/test.py index 7d80c585..62a58a77 100644 --- a/exercises/018-day_of_week/test.py +++ b/exercises/018-day_of_week/test.py @@ -14,11 +14,11 @@ def test_function_return(capsys, app): def test_function_return_type(capsys, app): assert type(app.day_of_week(1)) == type(1) -@pytest.mark.it('Something went wrong! We tried to pass 1 as parameter and it did not return 4! Keep trying!') +@pytest.mark.it('Something went wrong! We tried to pass 1 as parameter and it did not return 4. Keep trying!') def test_for_file_output(capsys, app): assert app.day_of_week(1) == 4 -@pytest.mark.it('Something went wrong! We tried to pass 46 as parameter and it did not return 4! Keep trying!') +@pytest.mark.it('Something went wrong! We tried to pass 46 as parameter and it did not return 0. Keep trying!') def test_for_file_output2(capsys, app): assert app.day_of_week(46) == 0 diff --git a/exercises/019-digital_clock/README.es.md b/exercises/019-digital_clock/README.es.md index a42383bc..9355f5c9 100644 --- a/exercises/019-digital_clock/README.es.md +++ b/exercises/019-digital_clock/README.es.md @@ -2,22 +2,24 @@ ## 📝 Instrucciones: -1. Dado un entero `N` que representa el número de minutos han pasado desde media noche, ¿cuántas horas y minutos se han mostrado en un reloj digital con formato 24 horas? Escribe una función `digital_clock()` para calcularlo. *La función debería imprimir dos números: el número de horas (entre 0 y 23) y el número de minutos (entre 0 y 59).* +1. Dado un entero `n` que representa el número de minutos que han pasado desde media noche, ¿cuántas horas y minutos se mostrarían en un reloj digital con formato 24 horas? Escribe una función `digital_clock()` para calcularlo. *La función debería imprimir dos números: el número de horas (entre 0 y 23) y el número de minutos (entre 0 y 59).* -## Ejemplo de entrada: +## 📎 Ejemplo de entrada: ```py digital_clock(150) ``` -## Ejemplo de salida: +## 📎 Ejemplo de salida: -+ (2, 30) +```py +(2, 30) +``` -Por ejemplo, si N = 150, entonces son 150 minutos que han pasado desde medianoche. Es decir, ahora son las 2:30 am, así que la función debería imprimir 2 30. +Por ejemplo, si n = 150, entonces son 150 minutos que han pasado desde medianoche. Es decir, ahora son las 2:30 am, así que la función debería imprimir (2, 30). ## 💡 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/ \ No newline at end of file ++ También puedes intentar paso a paso con trozos de la teoría: https://snakify.org/lessons/integer_float_numbers/steps/1/ diff --git a/exercises/019-digital_clock/README.md b/exercises/019-digital_clock/README.md index 250e4def..dc1b2f25 100644 --- a/exercises/019-digital_clock/README.md +++ b/exercises/019-digital_clock/README.md @@ -2,22 +2,24 @@ ## 📝 Instructions: -1. Given the integer `N` - the number of minutes that is passed since midnight. How many hours and minutes are displayed on the 24h digital clock? Write a `digital_clock()` function to calculate it. *The function should print two numbers: the number of hours (between 0 and 23) and the number of minutes (between 0 and 59).* +1. Given the integer `n` - the number of minutes that have passed since midnight, how many hours and minutes are displayed on the 24h digital clock? Write a `digital_clock()` function to calculate it. *The function should print two numbers: the number of hours (between 0 and 23) and the number of minutes (between 0 and 59).* -## Example input: +## 📎 Example input: ```py digital_clock(150) ``` -## Example output: +## 📎 Example output: -+ (2, 30) +```py +(2, 30) +``` -For example, if N = 150, then 150 minutes have passed since midnight - i.e. now is 2:30 am. So the function should print 2 30. +For example, if n = 150, then 150 minutes have passed since midnight - i.e. now is 2:30 am. So the function should print (2, 30). ## 💡 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/ \ No newline at end of file ++ You may also try step-by-step theory chunks: https://snakify.org/lessons/integer_float_numbers/steps/1/ diff --git a/exercises/019-digital_clock/app.py b/exercises/019-digital_clock/app.py index 8f9652f7..1862864d 100644 --- a/exercises/019-digital_clock/app.py +++ b/exercises/019-digital_clock/app.py @@ -1,6 +1,6 @@ -#Complete the function to return how many hrs and min are displayed on the 24th digital clock. +# Complete the function to return how many hours and minutes are displayed on the 24h digital clock def digital_clock(n): return None -#Invoke the function with any interger (seconds after midnight) +# Invoke the function with any integer (minutes after midnight) print(digital_clock()) diff --git a/exercises/019-digital_clock/solution.hide.py b/exercises/019-digital_clock/solution.hide.py index 997971b3..8125f691 100644 --- a/exercises/019-digital_clock/solution.hide.py +++ b/exercises/019-digital_clock/solution.hide.py @@ -1,6 +1,6 @@ -#Complete the function to return how many hrs and min are displayed on the 24th digital clock. +# Complete the function to return how many hours and minutes are displayed on the 24h digital clock def digital_clock(n): return ((n // 60), (n % 60)) -#Invoke the function with any interger (seconds after midnight) +# Invoke the function with any integer (minutes after midnight) print(digital_clock(150)) diff --git a/exercises/019-digital_clock/test.py b/exercises/019-digital_clock/test.py index a673e878..71e2f078 100644 --- a/exercises/019-digital_clock/test.py +++ b/exercises/019-digital_clock/test.py @@ -14,11 +14,11 @@ def test_function_return(capsys, app): def test_function_return_type(capsys, app): assert type(app.digital_clock(194)) == type((3, 14)) -@pytest.mark.it('We tried to pass 194 as parameter and it did not return (3, 14)!Keep Trying!') +@pytest.mark.it('We tried to pass 194 as parameter and it did not return (3, 14). Keep Trying!') def test_for_file_output(capsys, app): assert app.digital_clock(194) == (3, 14) -@pytest.mark.it('We tried to pass 150 as parameter and it did not return (2, 50)! Keep Trying!') +@pytest.mark.it('We tried to pass 150 as parameter and it did not return (2, 30). Keep Trying!') def test_for_file_output(capsys, app): - assert app.digital_clock(150) == (2,30) + assert app.digital_clock(150) == (2, 30) diff --git a/exercises/020-factorial/README.es.md b/exercises/020-factorial/README.es.md index 058652bb..e6501d90 100644 --- a/exercises/020-factorial/README.es.md +++ b/exercises/020-factorial/README.es.md @@ -2,17 +2,19 @@ ## 📝 Instrucciones: -1. Crea una función llamada `factorial()` que al recibir un número como parámatro retorne su valor factorial. +1. Crea una función llamada `factorial()`, que al recibir un número como parámetro retorne su valor factorial. -## Ejemplo de entrada: +## 📎 Ejemplo de entrada: ```py factorial(8) ``` -## Ejemplo de salida: +## 📎 Ejemplo de salida: -+ 40320 +```py +40320 +``` ## 💡 Pista: diff --git a/exercises/020-factorial/README.md b/exercises/020-factorial/README.md index 932ee8b2..a835ba34 100644 --- a/exercises/020-factorial/README.md +++ b/exercises/020-factorial/README.md @@ -2,17 +2,19 @@ ## 📝 Instructions: -1. Create a function named `factorial()` which receives a number as parameter and returns the factorial of the given number. +1. Create a function named `factorial()`, which receives a number as a parameter and returns the factorial of the given number. -## Example input: +## 📎 Example input: ```py factorial(8) ``` -## Example output: +## 📎 Example output: -+ 40320 +```py +40320 +``` ## 💡 Hint: diff --git a/exercises/020-factorial/solution.hide.py b/exercises/020-factorial/solution.hide.py index 0a188d3b..32326304 100644 --- a/exercises/020-factorial/solution.hide.py +++ b/exercises/020-factorial/solution.hide.py @@ -1,17 +1,17 @@ -def fact(x): - if x == 0: - return 1 - return x * fact(x - 1) - -x=int(input()) -print (fact(x)) - +# Your code here +def factorial(x): + result = 1 + for i in range(1, x + 1): + result *= i + return result -# or +print(factorial(5)) -# Your code here -import math -def factorial(num): - return math.factorial(num) +### Solution 2 ### -print(factorial(8)) \ No newline at end of file +# import math +# +# def factorial(x): +# return math.factorial(x) +# +# print(factorial(8)) diff --git a/exercises/020-factorial/test.py b/exercises/020-factorial/test.py index 04c23a6c..8360a6f1 100644 --- a/exercises/020-factorial/test.py +++ b/exercises/020-factorial/test.py @@ -13,7 +13,7 @@ def test_factorial_exists(app): def test_function_return(capsys, app): assert app.factorial(8) != None -@pytest.mark.it('The function must return a tuple') +@pytest.mark.it('The function must return a number') def test_function_return_type(capsys, app): assert type(app.factorial(8)) == type(1) @@ -36,4 +36,5 @@ def test_factorial_1(app): try: assert app.factorial(1) == 1 except AttributeError: - raise AttributeError("The function 'factorial' should return the value 1") \ No newline at end of file + raise AttributeError("The function 'factorial' should return the value 1") + diff --git a/exercises/22-Integral/README.es.md b/exercises/22-Integral/README.es.md index 5172b806..a554e3b3 100644 --- a/exercises/22-Integral/README.es.md +++ b/exercises/22-Integral/README.es.md @@ -1,11 +1,23 @@ # `22` Integral -Dado un número integral n, escribe un programa para generar un diccionario que contenga (i, i*i) como un número integrak entre 1 y n (ambos incluidos). Luego el programa debiese imprimir el diccionario. -Supongamos que se le entrega la siguiente entrada al programa: -8 -El resultado debiese ser: +## 📝 Instrucciones: + +1. Crea una función llamada `squares_dictionary()`. La función recibe un número `n` y debería generar un diccionario que contenga pares de la forma `(n: n*n)` para cada número en el rango de 1 a n, inclusive. + +2. Imprime el diccionario resultante. + +## 📎 Ejemplo de entrada: + +```py +squares_dictionary(8) +``` + +## 📎 Ejemplo de salida: + +```py {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64} +``` + +## 💡 Pista: -Pistas: -En el caso de que se le entreguen datos a la pregunta, deben asumirse como entradas de la consola. -Considera usar dict() ++ Un bucle `for` sería buena idea. diff --git a/exercises/22-Integral/README.md b/exercises/22-Integral/README.md index 515fbf6a..6856621f 100644 --- a/exercises/22-Integral/README.md +++ b/exercises/22-Integral/README.md @@ -1,11 +1,23 @@ # `22` Integral -With a given integral number n, write a program to generate a dictionary that contains (i, i*i) such that is an integral number between 1 and n (both included). Then the program should print the dictionary. -Suppose the following input is supplied to the program: -8 -Then, the output should be: +## 📝 Instructions: + +1. Create a function called `squares_dictionary()`. The function receives a number `n` and should generate a dictionary that contains pairs of the form `(n: n*n)` for each number in the range from 1 to n, inclusive. + +2. Print the resulting dictionary. + +## 📎 Example input: + +```py +squares_dictionary(8) +``` + +## 📎 Example output: + +```py {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64} +``` + +## 💡 Hint: -Hints: -In case of input data being supplied to the question, it should be assumed to be a console input. -Consider use dict() \ No newline at end of file ++ A `for` loop would be a good idea. diff --git a/exercises/22-Integral/app.py b/exercises/22-Integral/app.py index e69de29b..a51f0856 100644 --- a/exercises/22-Integral/app.py +++ b/exercises/22-Integral/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/exercises/22-Integral/solution.hide.py b/exercises/22-Integral/solution.hide.py index 262f2213..7d465a3a 100644 --- a/exercises/22-Integral/solution.hide.py +++ b/exercises/22-Integral/solution.hide.py @@ -1,7 +1,8 @@ -def generate_dict(n): - d=dict() - for i in range(1,n+1): - d[i]=i*i - return d +# Your code here +def squares_dictionary(n): + new_dict = dict() + for i in range(1, n + 1): + new_dict[i] = i * i + return new_dict -print(generate_dict(n)) \ No newline at end of file +print(squares_dictionary(5)) diff --git a/exercises/22-Integral/test.py b/exercises/22-Integral/test.py index ee977613..61500058 100644 --- a/exercises/22-Integral/test.py +++ b/exercises/22-Integral/test.py @@ -1,19 +1,18 @@ import pytest,os,re,io,sys, mock, json -@pytest.mark.it('The function generate_dict should exist') +@pytest.mark.it('The function squares_dictionary should exist') def test_function_existence(capsys, app): - assert app.generate_dict + assert app.squares_dictionary @pytest.mark.it('The function should return a dictionary') def test_typeof_return(capsys, app): - assert type(app.generate_dict(7)) == type({}) + assert type(app.squares_dictionary(7)) == type({}) -@pytest.mark.it('The function should return the expected output') +@pytest.mark.it('The function should return the expected output. Testing with 8') def test_expected_output(capsys, app): - assert app.generate_dict(8) == {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64} + assert app.squares_dictionary(8) == {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64} -@pytest.mark.it('The function should work with other entries') +@pytest.mark.it('The function should return the expected output. Testing with 5') def test_another_entry_5(capsys, app): - assert app.generate_dict(5) == {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} - + assert app.squares_dictionary(5) == {1: 1, 2: 4, 3: 9, 4: 16, 5: 25} diff --git a/exercises/23-list-and-tuple/README.es.md b/exercises/23-list-and-tuple/README.es.md index 3b9313cb..ddd8234d 100644 --- a/exercises/23-list-and-tuple/README.es.md +++ b/exercises/23-list-and-tuple/README.es.md @@ -1,12 +1,30 @@ -# `23` Lista y tupla +# `23` List and tuple -Escribe un programa que acepte una secuencia de números separados por comas desde la consola y genere una lista y una tupla que contenga todos los números. -Supongamos que se le entrega la siguiente entrada al programa: -34,67,55,33,12,98 -El resultado debiese ser: +## 📝 Instrucciones: + +1. Crea una función llamada `list_and_tuple()` que, dado un conjunto de `n` números como entrada, devuelve una lista y una tupla con esos números y los transforma a cada uno de ellos en string. + +2. Imprime la lista primero, y en la siguiente línea la tupla. + +## 📎 Ejemplo de entrada: + +```py +list_and_tuple(34,67,55,33,12,98) +``` + +## 📎 Ejemplo de salida: + +```py ['34', '67', '55', '33', '12', '98'] ('34', '67', '55', '33', '12', '98') +``` + +## 💡 Pistas: + ++ La cantidad de parámetros aceptados por la función no está limitado. + ++ Para crear una función que acepta un número ilimitado de argumentos, utiliza el operador `*` y luego cualquier nombre que desees. De esta forma: -Pistas: -En el caso de que se le entreguen entradas de datos a la pregunta, deben asumirse como entradas de la consola. -Usa el método tuple() para convertir la lista en una tupla. +```py +def my_function(*args) +``` diff --git a/exercises/23-list-and-tuple/README.md b/exercises/23-list-and-tuple/README.md index 15cbf7b1..623c8080 100644 --- a/exercises/23-list-and-tuple/README.md +++ b/exercises/23-list-and-tuple/README.md @@ -1,12 +1,30 @@ -# `23` List and touple +# `23` List and tuple -Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. -Suppose the following input is supplied to the program: -34,67,55,33,12,98 -Then, the output should be: +## 📝 Instructions: + +1. Create a function called `list_and_tuple()`, that given a input of `n` numbers returns a list and a tuple of those numbers and transforms each of them into a string. + +2. Print the list, and in the next line, print the tuple. + +## 📎 Example input: + +```py +list_and_tuple(34,67,55,33,12,98) +``` + +## 📎 Example output: + +```py ['34', '67', '55', '33', '12', '98'] ('34', '67', '55', '33', '12', '98') +``` + +## 💡 Hints: + ++ The number of parameters accepted by the function is not limited. + ++ To make a function that accepts an unlimited number of arguments, use the `*` operator and then any name you want for it. For example: -Hints: -In case of input data being supplied to the question, it should be assumed to be a console input. -tuple() method can convert list to tuple \ No newline at end of file +```py +def my_function(*args) +``` diff --git a/exercises/23-list-and-tuple/app.py b/exercises/23-list-and-tuple/app.py index e69de29b..a51f0856 100644 --- a/exercises/23-list-and-tuple/app.py +++ b/exercises/23-list-and-tuple/app.py @@ -0,0 +1 @@ +# Your code here diff --git a/exercises/23-list-and-tuple/solution.hide.py b/exercises/23-list-and-tuple/solution.hide.py index 8ca57f24..6dfa8b32 100644 --- a/exercises/23-list-and-tuple/solution.hide.py +++ b/exercises/23-list-and-tuple/solution.hide.py @@ -1,10 +1,11 @@ -values=input("") -l=values.split(",") -t=tuple(l) -print (l) -print (t) +# Your code here +def list_and_tuple(*nums): + new_list = [str(num) for num in nums] + new_tuple = tuple(new_list) + + return new_list, new_tuple -# -values=input("") -t=tuple(values.split(',')) -print(t) \ No newline at end of file + +result_list, result_tuple = list_and_tuple(5, 4, 13, 24, 45) +print(result_list) +print(result_tuple)