Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 25 additions & 0 deletions _sources/lectures/TWP15/TWP15_3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@ Algunos ejercicios
pero esta vez solo los números impares.

~~~~
def print_odd_numbers(n):


====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(print_odd_numbers(10), [1, 3, 5, 7, 9], "Esperado [1, 3, 5, 7, 9]")
self.assertEqual(print_odd_numbers(1), [1], "Esperado [1]")
self.assertEqual(print_odd_numbers(0), [], "Esperado []")

myTests().main()


.. activecode:: ac_l15_3e
Expand All @@ -59,3 +73,14 @@ Algunos ejercicios
Escriba un programa que imprima los primeros 10 múltiplos de 3.

~~~~
def print_multiples_of_3():

====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(print_multiples_of_3(), [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], "Esperado [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]")

myTests().main()
26 changes: 25 additions & 1 deletion _sources/lectures/TWP15/TWP15_3_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,35 @@ Some Exercises
the user, but this time only the odd numbers.

~~~~
def print_odd_numbers(n):


====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(print_odd_numbers(10), [1, 3, 5, 7, 9], "Expected [1, 3, 5, 7, 9]")
self.assertEqual(print_odd_numbers(1), [1], "Expected [1]")
self.assertEqual(print_odd_numbers(0), [], "Expected []")

myTests().main()

.. activecode:: ac_l15_3e_en
:nocodelens:

Write a program that prints the first 10 multiples of 3.

~~~~
~~~~
def print_multiples_of_3():

====
from unittest.gui import TestCaseGui


class myTests(TestCaseGui):
def testOne(self):
self.assertEqual(print_multiples_of_3(), [3, 6, 9, 12, 15, 18, 21, 24, 27, 30], "Expected [3, 6, 9, 12, 15, 18, 21, 24, 27, 30]")

myTests().main()