Skip to content

Commit 623e362

Browse files
committed
Adding the last conditional exercise to the rst
1 parent 16ebcfb commit 623e362

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

_sources/functions/func_Str_Cond.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,33 @@ The logical operators in Python are ``and``, ``or``, and ``not``. These can be u
445445
446446
myTests().main()
447447
448+
.. activecode:: fsc_ac_or_complex_cond
449+
:caption: complex conditional
450+
451+
Modify this code to use a complex conditional instead. It should still pass all tests. It should only take four lines of code or less.
452+
~~~~
453+
# function definition
454+
def either6(a,b):
455+
if a == 6:
456+
return True
457+
if b == 6:
458+
return True
459+
return False
460+
461+
====
462+
from unittest.gui import TestCaseGui
463+
464+
class myTests(TestCaseGui):
465+
466+
def testOne(self):
467+
self.assertEqual(either6(5,2),False,"either6(5,2)")
468+
self.assertEqual(either6(6,3),True, "either6(6,3)")
469+
self.assertEqual(either6(3,6),True, "either6(3,6)")
470+
self.assertEqual(either6(3,-6),False, "either6(3,6)")
471+
472+
myTests().main()
473+
474+
448475

449476
If you worked in a group, you can copy the answers from this page to the other group members. Select the group members below and click the button to share the answers.
450477

0 commit comments

Comments
 (0)