truth table: Binary Operations 4
requirements
preview
Here are the tests I have at the end of this chapter
1import src.truth_table
2import unittest
3
4
5class TestBinaryOperations(unittest.TestCase):
6
7 def test_contradiction(self):
8 self.assertFalse(
9 src.truth_table.contradiction(True, True)
10 )
11 self.assertFalse(
12 src.truth_table.contradiction(True, False)
13 )
14 self.assertFalse(
15 src.truth_table.contradiction(False, True)
16 )
17 self.assertFalse(
18 src.truth_table.contradiction(False, False)
19 )
20
21 def test_logical_conjunction(self):
22 self.assertTrue(
23 src.truth_table.logical_conjunction(True, True)
24 )
25 self.assertFalse(
26 src.truth_table.logical_conjunction(True, False)
27 )
28 self.assertFalse(
29 src.truth_table.logical_conjunction(False, True)
30 )
31 self.assertFalse(
32 src.truth_table.logical_conjunction(False, False)
33 )
34
35 def test_project_second(self):
36 self.assertTrue(
37 src.truth_table.project_second(True, True)
38 )
39 self.assertFalse(
40 src.truth_table.project_second(True, False)
41 )
42 self.assertTrue(
43 src.truth_table.project_second(False, True)
44 )
45 self.assertFalse(
46 src.truth_table.project_second(False, False)
47 )
48
49 def test_converse_non_implication(self):
50 self.assertFalse(
51 src.truth_table.converse_non_implication(True, True)
52 )
53 self.assertFalse(
54 src.truth_table.converse_non_implication(True, False)
55 )
56 self.assertTrue(
57 src.truth_table.converse_non_implication(False, True)
58 )
59 self.assertFalse(
60 src.truth_table.converse_non_implication(False, False)
61 )
62
63 def test_negate_first(self):
64 self.assertFalse(src.truth_table.negate_first(True, True))
65 self.assertFalse(src.truth_table.negate_first(True, False))
66 self.assertTrue(src.truth_table.negate_first(False, True))
67 self.assertTrue(src.truth_table.negate_first(False, False))
68
69 def test_logical_nand(self):
70 self.assertFalse(src.truth_table.logical_nand(True, True))
71 self.assertTrue(src.truth_table.logical_nand(True, False))
72 self.assertTrue(src.truth_table.logical_nand(False, True))
73 self.assertTrue(src.truth_table.logical_nand(False, False))
74
75 def test_tautology(self):
76 self.assertTrue(src.truth_table.tautology(True, True))
77 self.assertTrue(src.truth_table.tautology(True, False))
78 self.assertTrue(src.truth_table.tautology(False, True))
79 self.assertTrue(src.truth_table.tautology(False, False))
80
81 def test_logical_disjunction(self):
82 self.assertTrue(
83 src.truth_table.logical_disjunction(True, True)
84 )
85 self.assertTrue(
86 src.truth_table.logical_disjunction(True, False)
87 )
88 self.assertTrue(
89 src.truth_table.logical_disjunction(False, True)
90 )
91 self.assertFalse(
92 src.truth_table.logical_disjunction(False, False)
93 )
94
95 def test_exclusive_disjunction(self):
96 self.assertFalse(src.truth_table.exclusive_disjunction(True, True))
97 self.assertTrue(src.truth_table.exclusive_disjunction(True, False))
98 self.assertTrue(src.truth_table.exclusive_disjunction(False, True))
99 self.assertFalse(src.truth_table.exclusive_disjunction(False, False))
100
101 def test_material_non_implication(self):
102 self.assertFalse(
103 src.truth_table.material_non_implication(True, True)
104 )
105 self.assertTrue(
106 src.truth_table.material_non_implication(True, False)
107 )
108 self.assertFalse(
109 src.truth_table.material_non_implication(False, True)
110 )
111 self.assertFalse(
112 src.truth_table.material_non_implication(False, False)
113 )
114
115 def test_project_first(self):
116 self.assertTrue(src.truth_table.project_first(True, True))
117 self.assertTrue(src.truth_table.project_first(True, False))
118 self.assertFalse(src.truth_table.project_first(False, True))
119 self.assertFalse(src.truth_table.project_first(False, False))
120
121 def test_converse_implication(self):
122 self.assertTrue(src.truth_table.converse_implication(True, True))
123 self.assertTrue(src.truth_table.converse_implication(True, False))
124 self.assertFalse(src.truth_table.converse_implication(False, True))
125 self.assertTrue(src.truth_table.converse_implication(False, False))
126
127 def test_negate_second(self):
128 self.assertFalse(src.truth_table.negate_second(True, True))
129 self.assertTrue(src.truth_table.negate_second(True, False))
130 self.assertFalse(src.truth_table.negate_second(False, True))
131 self.assertTrue(src.truth_table.negate_second(False, False))
132
133 def test_logical_nor(self):
134 self.assertFalse(src.truth_table.logical_nor(True, True))
135 self.assertFalse(src.truth_table.logical_nor(True, False))
136 self.assertFalse(src.truth_table.logical_nor(False, True))
137 self.assertTrue(src.truth_table.logical_nor(False, False))
138
139 def test_logical_equality(self):
140 self.assertTrue(src.truth_table.logical_equality(True, True))
141 self.assertFalse(src.truth_table.logical_equality(True, False))
142 self.assertFalse(src.truth_table.logical_equality(False, True))
143 self.assertTrue(src.truth_table.logical_equality(False, False))
144
145 def test_material_implication(self):
146 self.assertTrue(src.truth_table.material_implication(True, True))
147 self.assertFalse(src.truth_table.material_implication(True, False))
148 self.assertTrue(src.truth_table.material_implication(False, True))
149 self.assertTrue(src.truth_table.material_implication(False, False))
150
151
152# Exceptions seen
153# AttributeError
154# TypeError
155# AssertionError
156# SyntaxError
continue the project
Make sure you are in the
pumping_pythonfolder with pwd in the terminalpwdif the terminal shows anything other than
.../pumping_pythonchange directory to the
pumping_pythonfolderOnce in
pumping_python, change directory to the projectcd truth_tablethe terminal shows
.../pumping_python/truth_tableI run the tests with pytest-watcher
uv run pytest-watcher . --nowthe terminal shows
rootdir: .../pumping_python/truth_table configfile: pyproject.toml collected 16 items tests/test_binary.py ................ [ 66%] tests/test_nullary_unary.py .... [100%] ======================== 16 passed in G.HIs ========================
test_negate_second
RED: make it fail
I add a new test with the first case for another Binary Operation - when the first input is True and the second input is True, to test_truth_table.py
127 def test_converse_implication(self):
128 self.assertTrue(src.truth_table.converse_implication(True, True))
129 self.assertTrue(src.truth_table.converse_implication(True, False))
130 self.assertFalse(src.truth_table.converse_implication(False, True))
131 self.assertTrue(src.truth_table.converse_implication(False, False))
132
133 def test_negate_second(self):
134 self.assertFalse(src.truth_table.negate_second(True, True))
135
136
137# Exceptions seen
the terminal shows AttributeError
AttributeError: module 'src.truth_table' has no attribute 'negate_second'
GREEN: make it pass
I add a function for negate_second to truth_table.py
69def converse_implication(first_input, second_input):
70 return first_input or not second_input
71
72
73def negate_second(first_input, second_input):
74 return False
the test passes. negate_second returns False, if the first input is True and the second input is True
REFACTOR: make it better
I add the next case - when the first input is True and the second input is False, to test_negate_second in
test_truth_table.py127 def test_negate_second(self): 128 self.assertFalse(src.truth_table.negate_second(True, True)) 129 self.assertTrue(src.truth_table.negate_second(True, False))the terminal shows AssertionError
AssertionError: False is not trueI add an if statement to negate_second in
truth_table.py73def negate_second(first_input, second_input): 74 if first_input == True and second_input == False: 75 return True 76 return Falsethe test passes. negate_second returns
I add the third case - when the first input is False and the second input is True, to test_negate_second in
test_truth_table.py127 def test_negate_second(self): 128 self.assertFalse(src.truth_table.negate_second(True, True)) 129 self.assertTrue(src.truth_table.negate_second(True, False)) 130 self.assertFalse(src.truth_table.negate_second(False, True))the test is still green. negate_second returns
False, if the first input is False and the second input is True
the logical negation of the second input in all 3 cases
I add the last case - when the first input is False and the second input is False
127 def test_negate_second(self): 128 self.assertFalse(src.truth_table.negate_second(True, True)) 129 self.assertTrue(src.truth_table.negate_second(True, False)) 130 self.assertFalse(src.truth_table.negate_second(False, True)) 131 self.assertTrue(src.truth_table.negate_second(False, False))the terminal shows AssertionError
AssertionError: False is not trueI add an if statement for the case to negate_second in
truth_table.py73def negate_second(first_input, second_input): 74 if first_input == False and second_input == False: 75 return True 76 if first_input == True and second_input == False: 77 return True 78 return Falsethe test passes. negate_second returns
True, if the first input is False and the second input is False
the logical negation of the second input in all 4 cases
I add a return statement to show that negate_second always returns the opposite of the second input
73def negate_second(first_input, second_input): 74 return not second_input 75 if first_input == False and second_input == False: 76 return True 77 if first_input == True and second_input == False: 78 return True 79 return Falsethe test is still green
I remove the other statements in the function
73def negate_second(first_input, second_input): 74 return not second_input
Negate Second always returns
not second_inputthe Logical Negation of the second input
It is the opposite (Logical Negation) of Project Second which always returns the second input
test_logical_nor
RED: make it fail
I add a test for logical_nor in test_truth_table.py
127 def test_negate_second(self):
128 self.assertFalse(src.truth_table.negate_second(True, True))
129 self.assertTrue(src.truth_table.negate_second(True, False))
130 self.assertFalse(src.truth_table.negate_second(False, True))
131 self.assertTrue(src.truth_table.negate_second(False, False))
132
133 def test_logical_nor(self):
134 self.assertFalse(src.truth_table.logical_nor(True, True))
135
136
137# Exceptions seen
the terminal shows AttributeError
AttributeError: module 'src.truth_table' has no attribute 'logical_nor'. Did you mean: 'logical_nand'?
GREEN: make it pass
I add the function to truth_table.py
73def negate_second(first_input, second_input):
74 return not second_input
75
76
77def logical_nor(first_input, second_input):
78 return False
the test passes. logical_nor returns False, if the first and second inputs are both True
REFACTOR: make it better
I add the second case - when the first input is True and the second input is False, to test_logical_nor in
test_truth_table.py133 def test_logical_nor(self): 134 self.assertFalse(src.truth_table.logical_nor(True, True)) 135 self.assertFalse(src.truth_table.logical_nor(True, False))the test is still green. logical_nor returns
on to the next case - when the first input is False and the second input is True
133 def test_logical_nor(self): 134 self.assertFalse(src.truth_table.logical_nor(True, True)) 135 self.assertFalse(src.truth_table.logical_nor(True, False)) 136 self.assertFalse(src.truth_table.logical_nor(False, True))the test is still green. logical_nor returns
I add the last case - when the first input is False and the second input is False
133 def test_logical_nor(self): 134 self.assertFalse(src.truth_table.logical_nor(True, True)) 135 self.assertFalse(src.truth_table.logical_nor(True, False)) 136 self.assertFalse(src.truth_table.logical_nor(False, True)) 137 self.assertTrue(src.truth_table.logical_nor(False, False)) 138 139 140# Exceptions seenthe terminal shows AssertionError
AssertionError: False is not trueI add an if statement for this case in
truth_table.py77def logical_nor(first_input, second_input): 78 if first_input == False and second_input == False: 79 return True 80 return Falsethe test passes. logical_nor returns
I make the if statement simpler
77def logical_nor(first_input, second_input): 78 # if first_input == False and second_input == False: 79 if not first_input and not second_input: 80 return True 81 return Falsethe test is still green
since
if something: return Trueis the same asreturn something, I use a conditional expression for the if statement intruth_table.py77def logical_nor(first_input, second_input): 78 return not first_input and not second_input 79 if not first_input and not second_input: 80 return True 81 return Falsestill green
I remove the other statements then factor out “not” because it happens 2 times
77def logical_nor(first_input, second_input): 78 return (not first_input) (not or) (not second_input) 79 return not first_input and not second_inputthe terminal shows SyntaxError
SyntaxError: invalid syntaxI add the correct statement
77def logical_nor(first_input, second_input): 78 # return (not first_input) (not or) (not second_input) 79 return not (first_input or second_input) 80 return not first_input and not second_inputgreen, green, green again 🎶
I remove the other statements in the function
77def logical_nor(first_input, second_input): 78 return not (first_input or second_input)
Logical NOR returns
not (first_input or second_input)True if the first input is False and the second input is False
the Logical Negation of the Logical Disjunction (or) of the first input and second input
test_logical_equality
RED: make it fail
I add a new test for the next Binary Operation in test_truth_table.py
133 def test_logical_nor(self):
134 self.assertFalse(src.truth_table.logical_nor(True, True))
135 self.assertFalse(src.truth_table.logical_nor(True, False))
136 self.assertFalse(src.truth_table.logical_nor(False, True))
137 self.assertTrue(src.truth_table.logical_nor(False, False))
138
139 def test_logical_equality(self):
140 self.assertTrue(src.truth_table.logical_equality(True, True))
141
142
143# Exceptions seen
the terminal shows AttributeError
AttributeError: module 'src.truth_table' has no attribute 'logical_equality'. Did you mean: 'logical_identity'?
GREEN: make it pass
I add a function for it in truth_table.py
77def logical_nor(first_input, second_input):
78 return not (first_input or second_input)
79
80
81def logical_equality(first_input, second_input):
82 return True
the test passes. logical_equality returns True, if the first input is True and the second input is True
REFACTOR: make it better
I add the next case to test_logical_equality in
test_truth_table.py139 def test_logical_equality(self): 140 self.assertTrue(src.truth_table.logical_equality(True, True)) 141 self.assertFalse(src.truth_table.logical_equality(True, False))the terminal shows AssertionError
AssertionError: True is not falseI add an if statement to logical_equality in
truth_table.py81def logical_equality(first_input, second_input): 82 if first_input and not second_input: 83 return False 84 return Truethe test passes. logical_equality returns
I add the next case to test_logical_equality in
test_truth_table.py139 def test_logical_equality(self): 140 self.assertTrue(src.truth_table.logical_equality(True, True)) 141 self.assertFalse(src.truth_table.logical_equality(True, False)) 142 self.assertFalse(src.truth_table.logical_equality(False, True))the terminal shows AssertionError
AssertionError: True is not falseI add another if statement to logical_equality in
truth_table.py81def logical_equality(first_input, second_input): 82 if not first_input and second_input: 83 return False 84 if first_input and not second_input: 85 return False 86 return Truethe test passes. logical_equality returns
I add the last case to test_logical_equality in
test_truth_table.py139 def test_logical_equality(self): 140 self.assertTrue(src.truth_table.logical_equality(True, True)) 141 self.assertFalse(src.truth_table.logical_equality(True, False)) 142 self.assertFalse(src.truth_table.logical_equality(False, True)) 143 self.assertTrue(src.truth_table.logical_equality(False, False)) 144 145 146# Exceptions seenthe test is still green. logical_equality returns
True, if the first input is False and the second input is False
False, if the first input is False and the second input is True
the logical_negation of the second input if the first input is False
False, if the first input is True and the second input is False
True, if the first input is True and the second input is True
the second input, if the first input is True
True, if the two inputs are the same
False, if the two inputs are NOT the same
I use “or” to put the 2 statements that return False together, since they are at the same level in logical_equality in
truth_table.py81def logical_equality(first_input, second_input): 82 # if not first_input and second_input: 83 # return False 84 # if first_input and not second_input: 85 # return False 86 if ( 87 (not first_input and second_input) 88 or 89 (first_input and not second_input) 90 ): 91 return False 92 return Truestill green
since
if something: return Falseis the same asreturn not (something), I remove the commented lines and use a conditional expression with not81def logical_equality(first_input, second_input): 82 return not ( 83 (not first_input and second_input) 84 or 85 (first_input and not second_input) 86 ) 87 if ( 88 (not first_input and second_input) 89 or 90 (first_input and not second_input) 91 ): 92 return False 93 return Truegreennn, yellow?
I remove the other statements in the function then “multiply not” by everything in the parentheses
81def logical_equality(first_input, second_input): 82 return ( 83 (not (not first_input and second_input)) 84 (not or) 85 (not (first_input and not second_input)) 86 ) 87 return not ( 88 (not first_input and second_input) 89 or 90 (first_input and not second_input) 91 )the terminal shows SyntaxError
SyntaxError: invalid syntax-
81def logical_equality(first_input, second_input): 82 return ( 83 (not (not first_input and second_input)) 84 and 85 (not (first_input and not second_input)) 86 ) 87 return not ( 88 (not first_input and second_input) 89 or 90 (first_input and not second_input) 91 )green again
I remove the other return statement then “multiply” “ not in the first parentheses
81def logical_equality(first_input, second_input): 82 return ( 83 # (not (not first_input and second_input)) 84 ((not not first_input) (not and) (not second_input)) 85 and 86 (not (first_input and not second_input)) 87 )the terminal shows SyntaxError
SyntaxError: invalid syntax-
81def logical_equality(first_input, second_input): 82 return ( 83 # (not (not first_input and second_input)) 84 ((not not first_input) or (not second_input)) 85 and 86 (not (first_input and not second_input)) 87 )the test is green again
I remove the commented line and “multiply” not in the next statement
81def logical_equality(first_input, second_input): 82 return ( 83 ((not not first_input) or (not second_input)) 84 and 85 # (not (first_input and not second_input)) 86 ((not first_input) (not and) (not not second_input)) 87 )the terminal shows SyntaxError
SyntaxError: invalid syntax-
81def logical_equality(first_input, second_input): 82 return ( 83 ((not not first_input) or (not second_input)) 84 and 85 # (not (first_input and not second_input)) 86 ((not first_input) or (not not second_input)) 87 )green again
I remove the commented line and
not notfrom both parentheses because they cancel out81def logical_equality(first_input, second_input): 82 return ( 83 (first_input or not second_input) 84 and 85 (not first_input or second_input) 86 )the test is still green
logical_equality returns True, if the first input and second input are the same, which means I can write a much simpler return statement thanks to the equality (
==) symbol (2 equal signs together =+=)81def logical_equality(first_input, second_input): 82 return first_input == second_input 83 return ( 84 (first_input or not second_input) 85 and 86 (not first_input or second_input) 87 )the test is still green
Logical Equality returns
first_input == second_inputTrue when the first input is equal to the second input
the Logical Conjunction of the result of the Logical Disjunction of the first input and the Logical Negation of the second input, and the result of the Logical Disjunction of the Logical Negation of the first input, and the second input. Oh brother!
is the opposite of Exclusive Disjunction which returns True, only if the first input and second input are NOT equal
test_material_implication
RED: make it fail
I add a new test for one more Binary Operation in test_truth_table.py
139 def test_logical_equality(self):
140 self.assertTrue(src.truth_table.logical_equality(True, True))
141 self.assertFalse(src.truth_table.logical_equality(True, False))
142 self.assertFalse(src.truth_table.logical_equality(False, True))
143 self.assertTrue(src.truth_table.logical_equality(False, False))
144
145 def test_material_implication(self):
146 self.assertTrue(src.truth_table.material_implication(True, True))
147
148
149# Exceptions seen
the terminal shows AttributeError
AttributeError: module 'src.truth_table' has no attribute 'material_implication'
GREEN: make it pass
I add a function for material_implication in truth_table.py
81def logical_equality(first_input, second_input):
82 return first_input == second_input
83 return (
84 (first_input or not second_input)
85 and
86 (not first_input or second_input)
87 )
88
89
90def material_implication(first_input, second_input):
91 return True
the test passes. material_implication returns True, if the first input is True and the second input is True
REFACTOR: make it better
I add the next case to test_material_implication in
test_truth_table.py145 def test_material_implication(self): 146 self.assertTrue(src.truth_table.material_implication(True, True)) 147 self.assertFalse(src.truth_table.material_implication(True, False))the terminal shows AssertionError
AssertionError: True is not falseI add an if statement to material_implication in
truth_table.py90def material_implication(first_input, second_input): 91 if first_input and not second_input: 92 return False 93 return Truethe test passes. material_implication returns
I add the next case to test_material_implication in
test_truth_table.py145 def test_material_implication(self): 146 self.assertTrue(src.truth_table.material_implication(True, True)) 147 self.assertFalse(src.truth_table.material_implication(True, False)) 148 self.assertTrue(src.truth_table.material_implication(False, True))the test is still green. material_implication returns
I add the fourth case
145 def test_material_implication(self): 146 self.assertTrue(src.truth_table.material_implication(True, True)) 147 self.assertFalse(src.truth_table.material_implication(True, False)) 148 self.assertTrue(src.truth_table.material_implication(False, True)) 149 self.assertTrue(src.truth_table.material_implication(False, False)) 150 151 152# Exceptions seenthe test is still green. material_implication returns
since
if something: return Falseis the same asreturn not (something), I add a return statement for the if statement in material_implication intruth_table.py90def material_implication(first_input, second_input): 91 return not (first_input and not second_input) 92 if first_input and not second_input: 93 return False 94 return Truethe test is still green
I remove the other statements in the function then “multiply not” by the symbols in the parentheses
90def material_implication(first_input, second_input): 91 return (not first_input) (not and) (not not second_input) 92 return not (first_input and not second_input)the terminal shows SyntaxError
SyntaxError: invalid syntax-
90def material_implication(first_input, second_input): 91 return (not first_input) or (not not second_input) 92 return not (first_input and not second_input)the test is green again
I remove
not not90def material_implication(first_input, second_input): 91 return not first_input or second_input 92 return (not first_input) or (not not second_input)still green
I remove the other statement
90def material_implication(first_input, second_input): 91 return not first_input or second_input
Material Implication also known as Logical Implication returns
not first_input or second_inputthe Logical Disjunction of the Logical Negation of the first input, and the second input
False only if the first input is True and the second input is False
it is the opposite (Logical Negation) of Material NonImplication which returns True only if the first input is True and the second input is False
more about Logical Equality
return ((first_input or not second_input) and (not first_input or second_input)) can be thought of as
return x or y
if
xisfirst_input or not second_inputif
yisnot first_input or second_input
Exclusive Disjunction can also be thought of as
return (
converse_implication(first_input, second_input)
and
material_implication(first_input, second_input)
)
because
converse_implication returns
first_input or not second_inputmaterial_implication return
not first_input or second_input
This means that in the 4 cases
if the first input is True and the second input is True, logical_equality returns
(first_input or not second_input) and (not first_input or second_input) (True or not True ) and (not True or True ) (True or False ) and (False or True ) True and True True # logical_conjunction(True, True)if the first input is True and the second input is False, logical_equality returns
(first_input or not second_input) and (not first_input or second_input) (True or not False ) and (not True or False ) (True or True ) and (False or False ) True and False False # logical_conjunction(True, False)if the first input is False and the second input is True, logical_equality returns
(first_input or not second_input) and (not first_input or second_input) (False or not True ) and (not False or True ) (False or False ) and (True or True ) False and True False # logical_conjunction(False, True)if the first input is False and the second input is False, logical_equality returns
(first_input or not second_input) and (not first_input or second_input) (False or not False ) and (not False or False ) (False or True ) and (True or False ) True and True True # logical_conjunction(True, True)
close the project
I close
test_truth_table.pyandtruth_table.pyin the editorI click in the terminal, then use q on the keyboard to leave the tests. The terminal goes back to the command line
I change directory to the parent of
truth_tablecd ..the terminal shows
.../pumping_pythonI am back in the
pumping_pythondirectory
review
Binary Operations take 2 inputs, each input can be True or False, if I name the first input first_input and the second one second_input, the tests show that
-
returns
not first_input or second_inputreturns False only if
first_inputis True andsecond_inputis Falseis the opposite (Logical Negation) of Material NonImplication which returns True only if
first_inputis True andsecond_inputis False
-
returns
first_input == second_inputreturns True only if
first_inputandsecond_inputare equalis the opposite (Logical Negation) of Exclusive Disjunction (Exclusive OR) which returns True only if
first_inputandsecond_inputare NOT equal
-
returns
not (first_input or second_input)returns True only if
first_inputis False andsecond_inputis Falseis the opposite (Logical Negation) of Logical Disjunction which returns False only if
first_inputis False andsecond_inputis False
-
always returns
not second_inputis the opposite (Logical Negation) of Project Second which returns True only if
second_inputis True
-
returns
first_input or not second_inputreturns False if
first_inputis False andsecond_inputis Trueis the opposite (Logical Negation) of Converse NonImplication which returns True only if
first_inputis False andsecond_inputis True
-
always returns
first_inputis the opposite (Logical Negation) of Negate First which returns True only if
first_inputis False
-
returns
first_input and not second_inputreturns True only if
first_inputis True andsecond_inputis Falseis the opposite (Logical Negation) of Material/Logical Implication which returns False only if
first_inputis True andsecond_inputis False
-
returns
first_input != second_inputreturns True only if
first_inputandsecond_inputare NOT equalis the opposite (Logical Negation) of Logical Equality which returns True only if
first_inputandsecond_inputare equal
-
returns
first_input or second_inputreturns False only if
first_inputis False andsecond_inputis Falseis the opposite (Logical Negation) of Logical NOR which returns True only if
first_inputis False andsecond_inputis False
-
always returns True
never returns False
is the opposite (Logical Negation) of contradiction which always returns False
-
returns
not (first_input and second_input)returns False only if
first_inputis True andsecond_inputis Trueis the opposite (Logical Negation) (not) of Logical Conjunction (and) which returns True only if
first_inputis True andsecond_inputis True
-
always returns
not first_inputis the opposite (Logical Negation) of Project First which returns True only if
first_inputis True
-
returns
not first_input and second_inputreturns True only if
first_inputis False andsecond_inputis Trueis the opposite (Logical Negation) of Converse Implication which returns False if
first_inputis False andsecond_inputis True
-
always returns
second_inputis the opposite (Logical Negation) of Negate Second which returns True only if
second_inputis False
Logical Conjunction returns
returns
first_input and second_inputreturns True only if
first_inputis True andsecond_inputis Trueis the opposite (Logical Negation) of Logical NAND which returns False only if
first_inputis True andsecond_inputis True
-
always returns False
never returns True
is the opposite (Logical Negation) of Tautology which always returns True
and
All the logic statements or conditions have been written with some or all of the above 3.
code from the chapter
Do you want to see all the CODE I typed for the Truth Table?
what is next?
rate pumping python
If this has been a 7 star experience for you, please CLICK HERE to leave a 5 star review of pumping python. It helps other people get into the book too