Skip to content

Commit

Permalink
update translation Quiz4_en.rst
Browse files Browse the repository at this point in the history
translated some functions and variables names
  • Loading branch information
ivannrnt authored May 20, 2024
1 parent 135ce0f commit 06327c1
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions _sources/quiz/Quiz4_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ Quiz - 4
.. activecode:: q4_1_en
:nocodelens:

Develop the function ``valores_extremos`` which takes the parameter ``numeros``, representing a list of **10** random numbers between 0-100.
The function should return a tuple ``(a, b)``, where a and b are the maximum and minimum values respectively of the ``numeros`` list. Solve the problem without using
Develop the function ``extreme_values`` which takes the parameter ``numbers``, representing a list of **10** random numbers between 0-100.
The function should return a tuple ``(a, b)``, where a and b are the maximum and minimum values respectively of the ``numbers`` list. Solve the problem without using
the functions ``max`` nor ``min``. |br| |br|
Example: |br|
``valores_extremos([15, 48, 0, 27, 13, 62, 32, 57, 85, 18])`` -> ``(85, 0)`` |br|
``extreme_values([15, 48, 0, 27, 13, 62, 32, 57, 85, 18])`` -> ``(85, 0)`` |br|

~~~~
def valores_extremos(numeros):
def extreme_values(numbers):


====
Expand All @@ -31,21 +31,21 @@ Quiz - 4

class myTests(TestCaseGui):
def testOne(self):
numeros = sample(range(100), 10)
numbers = sample(range(100), 10)
self.assertEqual(
valores_extremos(numeros), (max(numeros), min(numeros)), f"Expected: ({max(numeros)}, {min(numeros)})"
extreme_values(numbers), (max(numbers), min(numbers)), f"Expected: ({max(numbers)}, {min(numbers)})"
)

def testTwo(self):
numeros = sample(range(100), 10)
numbers = sample(range(100), 10)
self.assertEqual(
valores_extremos(numeros), (max(numeros), min(numeros)), f"Expected: ({max(numeros)}, {min(numeros)})"
extreme_values(numbers), (max(numbers), min(numbers)), f"Expected: ({max(numbers)}, {min(numbers)})"
)

def testThree(self):
numeros = sample(range(100), 10)
numbers = sample(range(100), 10)
self.assertEqual(
valores_extremos(numeros), (max(numeros), min(numeros)), f"Expected: ({max(numeros)}, {min(numeros)})"
extreme_values(numbers), (max(numbers), min(numbers)), f"Expected: ({max(numbers)}, {min(numbers)})"
)


Expand All @@ -57,12 +57,12 @@ Quiz - 4
.. activecode:: q4_2_en
:nocodelens:

Develop the function ``pares_e_impares`` which takes the parameter ``numeros``. ``numeros`` represents a list of **20** random numbers between 1-100.
Develop the function ``even_and_odd`` which takes the parameter ``numbers``. ``numbers`` represents a list of **20** random numbers between 1-100.
The function should return a tuple of lists of the form ``([even], [odd])``, where even and odd are lists of even and odd numbers that are
in ``numeros``, respectively. |br| |br|
in ``numbers``, respectively. |br| |br|

~~~~
def pares_e_impares(numeros):
def even_and_odd(numbers):


====
Expand All @@ -72,27 +72,27 @@ Quiz - 4

class myTests(TestCaseGui):
def testOne(self):
numeros = sample(range(1, 100), 20)
numbers = sample(range(1, 100), 20)
self.assertEqual(
pares_e_impares(numeros),
([n for n in numeros if n % 2 == 0], [n for n in numeros if n % 2 != 0]),
f"Expected: ({[n for n in numeros if n%2 == 0]}, {[n for n in numeros if n%2 != 0]})",
even_and_odd(numbers),
([n for n in numbers if n % 2 == 0], [n for n in numbers if n % 2 != 0]),
f"Expected: ({[n for n in numbers if n%2 == 0]}, {[n for n in numbers if n%2 != 0]})",
)

def testTwo(self):
numeros = sample(range(1, 100), 20)
numbers = sample(range(1, 100), 20)
self.assertEqual(
pares_e_impares(numeros),
([n for n in numeros if n % 2 == 0], [n for n in numeros if n % 2 != 0]),
f"Expected: ({[n for n in numeros if n%2 == 0]}, {[n for n in numeros if n%2 != 0]})",
even_and_odd(numbers),
([n for n in numbers if n % 2 == 0], [n for n in numbers if n % 2 != 0]),
f"Expected: ({[n for n in numbers if n%2 == 0]}, {[n for n in numbers if n%2 != 0]})",
)

def testThree(self):
numeros = sample(range(1, 100), 20)
numbers = sample(range(1, 100), 20)
self.assertEqual(
pares_e_impares(numeros),
([n for n in numeros if n % 2 == 0], [n for n in numeros if n % 2 != 0]),
f"Expected: ({[n for n in numeros if n%2 == 0]}, {[n for n in numeros if n%2 != 0]})",
even_and_odd(numbers),
([n for n in numbers if n % 2 == 0], [n for n in numbers if n % 2 != 0]),
f"Expected: ({[n for n in numbers if n%2 == 0]}, {[n for n in numbers if n%2 != 0]})",
)


Expand All @@ -104,13 +104,13 @@ Quiz - 4
.. activecode:: q4_3_en
:nocodelens:

Develop the function ``intercalar_listas`` which takes two parameters, ``l1`` and ``l2``, representing lists of **10** random numbers between 1-100.
Develop the function ``collate_lists`` which takes two parameters, ``l1`` and ``l2``, representing lists of **10** random numbers between 1-100.
The function should generate a third list composed of the elements of ``l1`` and ``l2`` interleaved. This third list will be returned. |br| |br|
Example: |br|
``intercalar_listas([1, 3, 5, .....], [2, 4, 6, ....])`` -> ``[1, 2, 3, 4, 5, 6, ....]`` |br|
``collate_lists([1, 3, 5, .....], [2, 4, 6, ....])`` -> ``[1, 2, 3, 4, 5, 6, ....]`` |br|

~~~~
def intercalar_listas(l1, l2):
def collate_lists(l1, l2):


====
Expand All @@ -123,7 +123,7 @@ Quiz - 4
l1 = sample(range(100), 10)
l2 = sample(range(100), 10)
self.assertEqual(
intercalar_listas(l1, l2),
collate_lists(l1, l2),
[val for pair in zip(l1, l2) for val in pair],
f"Expected: {[val for pair in zip(l1, l2) for val in pair]}",
)
Expand All @@ -132,7 +132,7 @@ Quiz - 4
l1 = sample(range(100), 10)
l2 = sample(range(100), 10)
self.assertEqual(
intercalar_listas(l1, l2),
collate_lists(l1, l2),
[val for pair in zip(l1, l2) for val in pair],
f"Expected: {[val for pair in zip(l1, l2) for val in pair]}",
)
Expand All @@ -146,7 +146,7 @@ Quiz - 4
.. activecode:: q4_4_en
:nocodelens:

The function ``buscar_palabras`` will be passed the following ``texto`` as argument: |br|
The function ``search_for_words`` will be passed the following ``text`` as argument: |br|
*"The Python Software Foundation and the global Python community welcome and encourage participation by everyone. Our community is based on
mutual respect, tolerance, and encouragement, and we are working to help each other live up to these principles. We want our community to be more diverse: whoever you are, and
whatever your background, we welcome you."* |br|
Expand All @@ -155,7 +155,7 @@ Quiz - 4
and be careful with capitalization. |br| |br|

~~~~
def buscar_palabras(texto):
def search_for_words(text):


====
Expand All @@ -174,7 +174,7 @@ Quiz - 4
for word in text.lower().replace(".", "").replace(",", "").split()
if word[0] in "python" or word[-1] in "python"
]
self.assertEqual(buscar_palabras(text), res, f"Expected: {res}")
self.assertEqual(search_for_words(text), res, f"Expected: {res}")


myTests().main()
Expand All @@ -185,12 +185,12 @@ Quiz - 4
.. activecode:: q4_5_en
:nocodelens:

Now you will develop the function ``buscar_palabras_2``, which will be passed the previous text as a parameter. Again you will separate the
text into words, just like you did in *Exercise 4*. This time, you should calculate the number of words within ``texto`` that have any
Now you will develop the function ``search_for_words_2``, which will be passed the previous text as a parameter. Again you will separate the
text into words, just like you did in *Exercise 4*. This time, you should calculate the number of words within ``text`` that have any
of the letters in the string ``"python"``, and also have a length greater than 4 characters. |br| |br|

~~~~
def buscar_palabras_2(texto):
def search_for_words_2(text):


====
Expand All @@ -203,7 +203,7 @@ Quiz - 4
encourage participation by everyone. Our community is based on mutual respect, tolerance, and encouragement,
and we are working to help each other live up to these principles. We want our community to be more diverse:
whoever you are, and whatever your background, we welcome you."""
self.assertEqual(buscar_palabras_2(text), 24, "Expected: 24")
self.assertEqual(search_for_words_2(text), 24, "Expected: 24")


myTests().main()
myTests().main()

0 comments on commit 06327c1

Please sign in to comment.