truth table: test_truth_table_tests
I want to write a program that makes the tests in test_truth_table.py pass without looking at them
requirements
continue the project
Make sure you are in the
pumping_pythonfolder with pwd in the terminalpwdif the terminal does not show
.../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 is my friend, and shows
rootdir: .../pumping_python/truth_table configfile: pyproject.toml collected 20 items tests/test_binary.py .................... [ 80%] tests/test_nullary_unary.py .... [100%] ======================== 20 passed in G.HIs ========================
RED: make it fail
I open
truth_table.pyfrom thesrcfolderI delete everything in
truth_table.py, the terminal is my friend, and shows 20 failures, I start with the last oneAttributeError: module 'src.truth_table' has no attribute 'logical_negation'because …
Can you make the tests pass without looking at how I solve it below? You can come back to compare solutions when you are done.
GREEN: make it pass
I add the name to
truth_table.py1logical_negationthe terminal is my friend, and shows NameError
NameError: name 'logical_negation' is not definedI point it to None to define it
1logical_negation = Nonethe terminal is my friend, and shows TypeError
TypeError: 'NoneType' object is not callablebecause I cannot call None like a function.
I make it a function
1# logical_negation 2def logical_negation(): 3 return Nonethe terminal is my friend, and shows TypeError
TypeError: logical_negation() takes 0 positional arguments but 1 was givenI add a name in parentheses
1# logical_negation 2# def logical_negation(): 3def logical_negation(something): 4 return Nonethe terminal is my friend, and shows AssertionError
AssertionError: None is not truethe assertion expects True.
I change None in the return statement to give the test what it wants
1# logical_negation 2# def logical_negation(): 3def logical_negation(something): 4 # return None 5 return Truethe terminal shows AssertionError
AssertionError: True is not falseI change the return statement
1# logical_negation 2# def logical_negation(): 3def logical_negation(something): 4 # return None 5 # return True 6 return Falsethe terminal is my friend, and shows AssertionError
AssertionError: False is not trueI change the return statement to see the difference between the input and what the assertion expects, remember the identity_function?
1# logical_negation 2# def logical_negation(): 3def logical_negation(something): 4 # return None 5 # return True 6 # return False 7 return somethingthe terminal is my friend, and shows AssertionError
AssertionError: True is not falseI use not in the return statement
1# logical_negation 2# def logical_negation(): 3def logical_negation(something): 4 # return None 5 # return True 6 # return False 7 # return something 8 return not somethingthe terminal shows
19 failed, 1 passed, progress! It also shows AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'logical_identity'I add a function for it
1# logical_negation 2# def logical_negation(): 3def logical_negation(something): 4 # return None 5 # return True 6 # return False 7 # return something 8 return not something 9 10 11def logical_identity(): 12 return Nonethe terminal is my friend, and shows TypeError
TypeError: logical_identity() takes 0 positional arguments but 1 was givenI add a name in parentheses
11# def logical_identity(): 12def logical_identity(something): 13 return Nonethe terminal is my friend, and shows AssertionError
AssertionError: None is not trueI change the return statement for logical_identity to give the test what it wants
11# def logical_identity(): 12def logical_identity(something): 13 # return None 14 return Truethe terminal is my friend, and shows AssertionError
AssertionError: True is not falseI change the return statement
11# def logical_identity(): 12def logical_identity(something): 13 # return None 14 # return True 15 return Falsethe terminal is my friend, and shows AssertionError
AssertionError: False is not truethe function returned
I change the return statement to see the difference between the input and what the assertion expects
11# def logical_identity(): 12def logical_identity(something): 13 # return None 14 # return True 15 # return False 16 return somethingthe terminal shows
18 failed, 2 passed, more progress! It also shows AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'logical_true'I add the function
11# def logical_identity(): 12def logical_identity(something): 13 # return None 14 # return True 15 # return False 16 return something 17 18 19def logical_true(): 20 return Nonethe terminal is my friend, and shows AssertionError
AssertionError: None is not trueI change the return statement for logical_true to give the test what it wants
19def logical_true(): 20 # return None 21 return True17 failed, 3 passed. That was simple. the terminal is my friend, and shows AttributeError
AttributeError: module 'src.truth_table' has no attribute 'logical_false'. Did you mean: 'logical_true'?I add the function
19def logical_true(): 20 # return None 21 return True 22 23 24def logical_false(): 25 return Nonethe terminal shows
16 failed, 4 passed, simple again. I am getting it. The terminal also shows AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'tautology'I add the function
24def logical_false(): 25 return None 26 27 28def tautology(): 29 return Nonethe terminal is my friend, and shows TypeError
TypeError: tautology() takes 0 positional arguments but 2 were givenI add two names in parentheses for the function to take input arguments
28# def tautology(): 29def tautology(first, second): 30 return Nonethe terminal is my friend, and shows AssertionError
AssertionError: None is not trueI change None to True in the return statement
28# def tautology(): 29def tautology(first, second): 30 # return None 31 return Truethe terminal shows
15 failed, 5 passed, Yes! It also shows AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'project_second'I add the function
28# def tautology(): 29def tautology(first, second): 30 # return None 31 return True 32 33 34def project_second(): 35 return Nonethe terminal is my friend, and shows TypeError
TypeError: project_second() takes 0 positional arguments but 2 were givenI add two names in parentheses for the function to take input arguments
34# def project_second(): 35def project_second(first, second): 36 return Nonethe terminal is my friend, and shows AssertionError
AssertionError: None is not trueI change the return statement to give the test what it wants
34# def project_second(): 35def project_second(first, second): 36 # return None 37 return Truethe terminal is my friend, and shows AssertionError
AssertionError: True is not falseI change the return statement
34# def project_second(): 35def project_second(first, second): 36 # return None 37 # return True 38 return Falsethe terminal is my friend, and shows AssertionError
AssertionError: False is not truethe function returned
I change the return statement to see the difference between the input and what the assertion expects
34# def project_second(): 35def project_second(first, second): 36 # return None 37 # return True 38 # return False 39 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, False) is not falsesecondis False and is equal to the expectation of the assertion.I remove
firstfrom the return statement sincesecondis False34# def project_second(): 35def project_second(first, second): 36 # return None 37 # return True 38 # return False 39 # return first, second 40 return secondthe terminal shows
14 failed, 6 passed, and AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'project_first'I add a function for it
34# def project_second(): 35def project_second(first, second): 36 # return None 37 # return True 38 # return False 39 # return first, second 40 return second 41 42 43def project_first(): 44 return Nonethe terminal is my friend, and shows TypeError
TypeError: project_first() takes 0 positional arguments but 2 were givenokay, I have seen this before.
I add 2 names in the parentheses
43# def project_first(): 44def project_first(first, second): 45 return Nonethe terminal is my friend, and shows AssertionError
AssertionError: None is not trueI change the return statement to give the test what it wants
43# def project_first(): 44def project_first(first, second): 45 # return None 46 return Truethe terminal is my friend, and shows AssertionError
AssertionError: True is not falseI change the return statement
43# def project_first(): 44def project_first(first, second): 45 # return None 46 # return True 47 return Falsethe terminal is my friend, and shows AssertionError
AssertionError: False is not truethe function returned
I change the return statement to see the difference between the input and what the assertion expects
43# def project_first(): 44def project_first(first, second): 45 # return None 46 # return True 47 # return False 48 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, True) is not falsesecondis True and is equal to the expectation of the assertion.I remove
secondfrom the return statement sincefirstis False43# def project_first(): 44def project_first(first, second): 45 # return None 46 # return True 47 # return False 48 # return first, second 49 return firstthe terminal shows
13 failed, 7 passed, and AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'negate_second'I add a function for negate_second with a return statement to see the difference between the input and what the assertion expects
43# def project_first(): 44def project_first(first, second): 45 # return None 46 # return True 47 # return False 48 # return first, second 49 return first 50 51 52def negate_second(first, second): 53 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, True) is not falseI add an if statement to negate_second since
firstandsecondare both not False52def negate_second(first, second): 53 if (first, second) == (True, True): return False 54 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, True) is not falseI add another if statement
52def negate_second(first, second): 53 if (first, second) == (True, True): return False 54 if (first, second) == (False, True): return False 55 return first, secondthe terminal is my friend, and shows
12 failed, 8 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'negate_first'I add a function for it with a return statement to see the difference between the input and what the assertion expects
52def negate_second(first, second): 53 if (first, second) == (True, True): return False 54 if (first, second) == (False, True): return False 55 return first, second 56 57 58def negate_first(first, second): 59 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, True)I add an if statement since
firstandsecondare both not False58def negate_first(first, second): 59 if (first, second) == (True, True): return False 60 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, False) is not falseI add another if statement
58def negate_first(first, second): 59 if (first, second) == (True, True): return False 60 if (first, second) == (True, False): return False 61 return first, secondthe terminal is my friend, and shows
11 failed, 9 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'material_non_implication'I add a function for material_non_implication with a return statement to see the difference between the input and what the assertion expects
58def negate_first(first, second): 59 if (first, second) == (True, True): return False 60 if (first, second) == (True, False): return False 61 return first, second 62 63 64def material_non_implication(first, second): 65 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, True) is not falseI add an if statement since
firstandsecondare both not False64def material_non_implication(first, second): 65 if (first, second) == (True, True): return False 66 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, True) is not falseI add another if statement
64def material_non_implication(first, second): 65 if (first, second) == (True, True): return False 66 if (first, second) == (False, True): return False 67 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, False) is not falseI add an if statement for it
64def material_non_implication(first, second): 65 if (first, second) == (True, True): return False 66 if (first, second) == (False, True): return False 67 if (first, second) == (False, False): return False 68 return first, secondthe terminal is my friend, and shows
10 failed, 10 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'material_implication'I add a function for material_implication with a return statement to see the difference between the input and what the assertion expects
64def material_non_implication(first, second): 65 if (first, second) == (True, True): return False 66 if (first, second) == (False, True): return False 67 if (first, second) == (False, False): return False 68 return first, second 69 70 71def material_implication(first, second): 72 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, False) is not falseI add an if statement for it
71def material_implication(first, second): 72 if (first, second) == (True, False): return False 73 return first, secondthe terminal is my friend, and shows
9 failed, 11 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'logical_nor'I add a function for logical_nor
71def material_implication(first, second): 72 if (first, second) == (True, False): return False 73 return first, second 74 75 76def logical_nor(first, second): 77 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, True) is not falseI add an if statement
76def logical_nor(first, second): 77 if (first, second) == (True, True): return False 78 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, False) is not falseI add another if statement
76def logical_nor(first, second): 77 if (first, second) == (True, True): return False 78 if (first, second) == (True, False): return False 79 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, True) is not falseI add an if statement
76def logical_nor(first, second): 77 if (first, second) == (True, True): return False 78 if (first, second) == (True, False): return False 79 if (first, second) == (False, True): return False 80 return first, secondthe terminal is my friend, and shows
8 failed, 12 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'logical_nand'. Did you mean: 'logical_nor'?I add a function for logical_nand
76def logical_nor(first, second): 77 if (first, second) == (True, True): return False 78 if (first, second) == (True, False): return False 79 if (first, second) == (False, True): return False 80 return first, second 81 82 83def logical_nand(first, second): 84 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, True) is not falseI add an if statement
83def logical_nand(first, second): 84 if (first, second) == (True, True): return False 85 return first, secondthe terminal is my friend, and shows
7 failed, 13 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'logical_equality'. Did you mean: 'logical_identity'?I add the function
83def logical_nand(first, second): 84 if (first, second) == (True, True): return False 85 return first, second 86 87 88def logical_equality(first, second): 89 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, False) is not falseI add an if statement
88def logical_equality(first, second): 89 if (first, second) == (True, False): return False 90 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, True) is not falseI add another if statement
88def logical_equality(first, second): 89 if (first, second) == (True, False): return False 90 if (first, second) == (False, True): return False 91 return first, secondthe terminal is my friend, and shows
6 failed, 14 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'logical_disjunction'I add a function for logical_disjunction
88def logical_equality(first, second): 89 if (first, second) == (True, False): return False 90 if (first, second) == (False, True): return False 91 return first, second 92 93 94def logical_disjunction(first, second): 95 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, False) is not falseI add an if statement
94def logical_disjunction(first, second): 95 if (first, second) == (False, False): return False 96 return first, secondthe terminal is my friend, and shows
5 failed, 15 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'logical_conjunction'. Did you mean: 'logical_disjunction'?I add a function for logical_conjunction
94def logical_disjunction(first, second): 95 if (first, second) == (False, False): return False 96 return first, second 97 98 99def logical_conjunction(first, second): 100 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, False) is not falseI add an if statement
99def logical_conjunction(first, second): 100 if (first, second) == (True, False): return False 101 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, True) is not falseI add an if statement
99def logical_conjunction(first, second): 100 if (first, second) == (True, False): return False 101 if (first, second) == (False, True): return False 102 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, False) is not falseI add another if statement
99def logical_conjunction(first, second): 100 if (first, second) == (True, False): return False 101 if (first, second) == (False, True): return False 102 if (first, second) == (False, False): return False 103 return first, secondthe terminal is my friend, and shows
4 failed, 16 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'exclusive_disjunction'I add a function for exclusive_disjunction
99def logical_conjunction(first, second): 100 if (first, second) == (True, False): return False 101 if (first, second) == (False, True): return False 102 if (first, second) == (False, False): return False 103 return first, second 104 105 106def exclusive_disjunction(first, second): 107 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, True) is not falseI add an if statement
106def exclusive_disjunction(first, second): 107 if (first, second) == (True, True): return False 108 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, False) is not falseI add another if statement
106def exclusive_disjunction(first, second): 107 if (first, second) == (True, True): return False 108 if (first, second) == (False, False): return False 109 return first, secondthe terminal is my friend, and shows
3 failed, 17 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'converse_non_implication'. Did you mean: 'material_non_implication'?I add converse_non_implication
106def exclusive_disjunction(first, second): 107 if (first, second) == (True, True): return False 108 if (first, second) == (False, False): return False 109 return first, second 110 111 112def converse_non_implication(first, second): 113 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, True) is not falseI add an if statement
112def converse_non_implication(first, second): 113 if (first, second) == (True, True): return False 114 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, False) is not falseI add another if statement
112def converse_non_implication(first, second): 113 if (first, second) == (True, True): return False 114 if (first, second) == (True, False): return False 115 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, False) is not falseI add an if statement
112def converse_non_implication(first, second): 113 if (first, second) == (True, True): return False 114 if (first, second) == (True, False): return False 115 if (first, second) == (False, False): return False 116 return first, secondthe terminal is my friend, and shows
2 passed, 18 failedfor AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'converse_implication'. Did you mean: 'converse_non_implication'?I add converse_implication
112def converse_non_implication(first, second): 113 if (first, second) == (True, True): return False 114 if (first, second) == (True, False): return False 115 if (first, second) == (False, False): return False 116 return first, second 117 118 119def converse_implication(first, second): 120 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, True) is not falseI add an if statement
119def converse_implication(first, second): 120 if (first, second) == (False, True): return False 121 return first, secondthe terminal is my friend, and shows
1 failed, 19 passedwith AttributeErrorAttributeError: module 'src.truth_table' has no attribute 'contradiction'I add contradiction
119def converse_implication(first, second): 120 if (first, second) == (False, True): return False 121 return first, second 122 123 124def contradiction(first, second): 125 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, True) is not falseI add an if statement
124def contradiction(first, second): 125 if (first, second) == (True, True): return False 126 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (True, False) is not falseI add another if statement
124def contradiction(first, second): 125 if (first, second) == (True, True): return False 126 if (first, second) == (True, False): return False 127 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, True) is not falseI add another if statement
124def contradiction(first, second): 125 if (first, second) == (True, True): return False 126 if (first, second) == (True, False): return False 127 if (first, second) == (False, True): return False 128 return first, secondthe terminal is my friend, and shows AssertionError
AssertionError: (False, False) is not falseI add an if statement
124def contradiction(first, second): 125 if (first, second) == (True, True): return False 126 if (first, second) == (True, False): return False 127 if (first, second) == (False, True): return False 128 if (first, second) == (False, False): return False 129 return first, secondthe terminal is my friend, and shows
======================== 20 passed in G.HIs ========================
All the tests are passing and the world is a better place than when I started! I am going home.
REFACTOR: make it better
Wait, there is more… Since all the tests are passing, I can play with the functions I have to make them simpler and understand why my solutions work.
contradiction returns False in 4 cases, with 2 inputs there are only 4 cases. I add a return statement
124def contradiction(first, second): 125 # if (first, second) == (True, True): return False 126 # if (first, second) == (True, False): return False 127 # if (first, second) == (False, True): return False 128 # if (first, second) == (False, False): return False 129 # return first, second 130 return Falsethe test is still green.
I remove the commented lines from contradiction
124def contradiction(first, second): 125 return False
converse_implication returns False in only one case. I write out the if statement for that case, to make it clearer
119def converse_implication(first, second): 120 # if (first, second) == (False, True): return False 121 if first == False and second == True: 122 return False 123 return first, secondstill green.
I change the statement with not and True
119def converse_implication(first, second): 120 # if (first, second) == (False, True): return False 121 # if first == False and second == True: 122 if not first == True and second == True: 123 return False 124 return first, secondgreen.
I remove
== True119def converse_implication(first, second): 120 # if (first, second) == (False, True): return False 121 # if first == False and second == True: 122 # if not first == True and second == True: 123 if not first and second: 124 return False 125 return first, secondstill green.
I add a return statement because
if something: return Falsecan be written asreturn not (something)119def converse_implication(first, second): 120 # if (first, second) == (False, True): return False 121 # if first == False and second == True: 122 # if not first == True and second == True: 123 # if not first and second: 124 # return False 125 # return first, second 126 return not (not first and second)the test is still green.
I “multiply not” by the things in the parentheses
119def converse_implication(first, second): 120 # if (first, second) == (False, True): return False 121 # if first == False and second == True: 122 # if not first == True and second == True: 123 # if not first and second: 124 # return False 125 # return first, second 126 # return not (not first and second) 127 return (not not first) (not and) (not second)the terminal is my friend, and shows SyntaxError
SyntaxError: invalid syntaxI change
not andto or119def converse_implication(first, second): 120 # if (first, second) == (False, True): return False 121 # if first == False and second == True: 122 # if not first == True and second == True: 123 # if not first and second: 124 # return False 125 # return first, second 126 # return not (not first and second) 127 # return (not not first) (not and) (not second) 128 return (not not first) or (not second)the test is green again.
I remove
not notbecause two nots make a right?119def converse_implication(first, second): 120 # if (first, second) == (False, True): return False 121 # if first == False and second == True: 122 # if not first == True and second == True: 123 # if not first and second: 124 # return False 125 # return first, second 126 # return not (not first and second) 127 # return (not not first) (not and) (not second) 128 # return (not not first) or (not second) 129 return first or not secondI remove the commented lines
119def converse_implication(first, second): 120 return first or not second 121 122 123def contradiction(first, second): 124 return False
I add an if statement for the only case that returns True in converse_non_implication
112def converse_non_implication(first, second): 113 # if (first, second) == (True, True): return False 114 # if (first, second) == (True, False): return False 115 # if (first, second) == (False, False): return False 116 # return first, second 117 if first == False and second == True: 118 return True 119 else: 120 return Falsethe test is still green.
I change
if first == Falseto terms of True112def converse_non_implication(first, second): 113 # if (first, second) == (True, True): return False 114 # if (first, second) == (True, False): return False 115 # if (first, second) == (False, False): return False 116 # return first, second 117 # if first == False and second == True: 118 if not first == True and second == True: 119 return True 120 else: 121 return Falsegreen.
I remove
== True112def converse_non_implication(first, second): 113 # if (first, second) == (True, True): return False 114 # if (first, second) == (True, False): return False 115 # if (first, second) == (False, False): return False 116 # return first, second 117 # if first == False and second == True: 118 # if not first == True and second == True: 119 if not first and second: 120 return True 121 else: 122 return Falsestill green.
I add a return statement because
if something: return Truecan be written asreturn somethingsincesomethingis grouped as True112def converse_non_implication(first, second): 113 # if (first, second) == (True, True): return False 114 # if (first, second) == (True, False): return False 115 # if (first, second) == (False, False): return False 116 # return first, second 117 # if first == False and second == True: 118 # if not first == True and second == True: 119 # if not first and second: 120 # return True 121 # else: 122 # return False 123 return not first and secondthe test is still green.
I remove the commented lines
112def converse_non_implication(first, second): 113 return not first and second 114 115 116def converse_implication(first, second): 117 return first or not second 118 119 120def contradiction(first, second): 121 return False
I make the if statements in exclusive_disjunction simpler
106def exclusive_disjunction(first, second): 107 # if (first, second) == (True, True): return False 108 # if (first, second) == (False, False): return False 109 # return first, second 110 if first == True and second == True: 111 return False 112 if first == False and second == False: 113 return False 114 return Truethe test is still green.
I change the new second if statement with not and True
106def exclusive_disjunction(first, second): 107 # if (first, second) == (True, True): return False 108 # if (first, second) == (False, False): return False 109 # return first, second 110 if first == True and second == True: 111 return False 112 # if first == False and second == False: 113 if not first == True and not second == True: 114 return False 115 return Truestill green.
I remove
== True106def exclusive_disjunction(first, second): 107 # if (first, second) == (True, True): return False 108 # if (first, second) == (False, False): return False 109 # return first, second 110 # if first == True and second == True: 111 if first and second: 112 return False 113 # if first == False and second == False: 114 # if not first == True and not second == True: 115 if not first and not second: 116 return False 117 return Truegreen.
I write everything in the second if statement with not because it happens two times in the line, I might as well make it three
106def exclusive_disjunction(first, second): 107 # if (first, second) == (True, True): return False 108 # if (first, second) == (False, False): return False 109 # return first, second 110 # if first == True and second == True: 111 if first and second: 112 return False 113 # if first == False and second == False: 114 # if not first == True and not second == True: 115 # if not first and not second: 116 if (not first) (not or) (not second): 117 return False 118 return Truethe terminal is my friend, and shows SyntaxError
SyntaxError: invalid syntaxI factor out the nots
106def exclusive_disjunction(first, second): 107 # if (first, second) == (True, True): return False 108 # if (first, second) == (False, False): return False 109 # return first, second 110 # if first == True and second == True: 111 if first and second: 112 return False 113 # if first == False and second == False: 114 # if not first == True and not second == True: 115 # if not first and not second: 116 # if (not first) (not or) (not second): 117 if not (first or second): 118 return False 119 return Truethe test is green .
I put the two if statements together as one
106def exclusive_disjunction(first, second): 107 # if (first, second) == (True, True): return False 108 # if (first, second) == (False, False): return False 109 # return first, second 110 # if first == True and second == True: 111 # if first and second: 112 # return False 113 # if first == False and second == False: 114 # if not first == True and not second == True: 115 # if not first and not second: 116 # if (not first) (not or) (not second): 117 # if not (first or second): 118 if ( 119 (first and second) 120 or 121 (not (first or second)) 122 ): 123 return False 124 return Truethe test is still green.
I add a return statement because
if something: return Falsecan be written asreturn not (something)106def exclusive_disjunction(first, second): 107 # if (first, second) == (True, True): return False 108 # if (first, second) == (False, False): return False 109 # return first, second 110 # if first == True and second == True: 111 # if first and second: 112 # return False 113 # if first == False and second == False: 114 # if not first == True and not second == True: 115 # if not first and not second: 116 # if (not first) (not or) (not second): 117 # if not (first or second): 118 # if ( 119 # (first and second) 120 # or 121 # (not (first or second)) 122 # ): 123 # return False 124 # return True 125 return not ( 126 (first and second) 127 or 128 (not (first or second)) 129 )still green.
I “multiply” not by everything in the parentheses since it happens two times in the line
106def exclusive_disjunction(first, second): 107 # if (first, second) == (True, True): return False 108 # if (first, second) == (False, False): return False 109 # return first, second 110 # if first == True and second == True: 111 # if first and second: 112 # return False 113 # if first == False and second == False: 114 # if not first == True and not second == True: 115 # if not first and not second: 116 # if (not first) (not or) (not second): 117 # if not (first or second): 118 # if ( 119 # (first and second) 120 # or 121 # (not (first or second)) 122 # ): 123 # return False 124 # return True 125 # return not ( 126 # (first and second) 127 # or 128 # (not (first or second)) 129 # ) 130 return ( 131 (not (first and second)) 132 (not or) 133 (not (not (first or second))) 134 )the terminal shows SyntaxError
SyntaxError: invalid syntaxI change
not orto and130 return ( 131 (not (first and second)) 132 # (not or) 133 and 134 (not (not (first or second))) 135 )the test is green again.
I remove
not notbecause “the negation of a negation is …”130 return ( 131 (not (first and second)) 132 # (not or) 133 and 134 # (not (not (first or second))) 135 (first or second) 136 )green.
I remove the commented lines from exclusive_disjunction
106def exclusive_disjunction(first, second): 107 return (not (first and second)) and (first or second) 108 109 110def converse_non_implication(first, second): 111 return not first and second 112 113 114def converse_implication(first, second): 115 return first or not second 116 117 118def contradiction(first, second): 119 return False
logical_conjunction has only one case that returns True. I add an if statement for it
99def logical_conjunction(first, second): 100 # if (first, second) == (True, False): return False 101 # if (first, second) == (False, True): return False 102 # if (first, second) == (False, False): return False 103 # return first, second 104 if first == True and second == True: 105 return True 106 else: 107 return Falsethe test is still green.
I remove
== True99def logical_conjunction(first, second): 100 # if (first, second) == (True, False): return False 101 # if (first, second) == (False, True): return False 102 # if (first, second) == (False, False): return False 103 # return first, second 104 # if first == True and second == True: 105 if first and second: 106 return True 107 else: 108 return Falsestill green.
I add a return statement because
if something: return Truecan be written asreturn somethingsincesomethingis grouped as True99def logical_conjunction(first, second): 100 # if (first, second) == (True, False): return False 101 # if (first, second) == (False, True): return False 102 # if (first, second) == (False, False): return False 103 # return first, second 104 # if first == True and second == True: 105 # if first and second: 106 # return True 107 # else: 108 # return False 109 return first and secondgreen.
I remove the commented lines from logical_conjunction
99def logical_conjunction(first, second): 100 return first and second 101 102 103def exclusive_disjunction(first, second): 104 return (not (first and second)) and (first or second)
logical_disjunction has only one case that returns False, I break up the if statement
94def logical_disjunction(first, second): 95 # if (first, second) == (False, False): return False 96 # return first, second 97 if first == False and second == False: 98 return False 99 else: 100 return Truethe test is still green.
I then change the if statement with not and True
94def logical_disjunction(first, second): 95 # if (first, second) == (False, False): return False 96 # return first, second 97 # if first == False and second == False: 98 if not first == True and not second == True: 99 return False 100 else: 101 return Truestill green.
I remove
== True94def logical_disjunction(first, second): 95 # if (first, second) == (False, False): return False 96 # return first, second 97 # if first == False and second == False: 98 # if not first == True and not second == True: 99 if not first and not second: 100 return False 101 else: 102 return Truegreen.
I change the statement with not since it happens two times
94def logical_disjunction(first, second): 95 # if (first, second) == (False, False): return False 96 # return first, second 97 # if first == False and second == False: 98 # if not first == True and not second == True: 99 # if not first and not second: 100 if (not first) (not or) (not second): 101 return False 102 else: 103 return Truethe terminal is my friend, and shows SyntaxError
SyntaxError: invalid syntaxI factor out not
94def logical_disjunction(first, second): 95 # if (first, second) == (False, False): return False 96 # return first, second 97 # if first == False and second == False: 98 # if not first == True and not second == True: 99 # if not first and not second: 100 # if (not first) (not or) (not second): 101 if not (first or second): 102 return False 103 else: 104 return Truethe test is green again.
I add a return statement for the opposite of the if statement because
if something: return Falsecan be written asreturn not (something)94def logical_disjunction(first, second): 95 # if (first, second) == (False, False): return False 96 # return first, second 97 # if first == False and second == False: 98 # if not first == True and not second == True: 99 # if not first and not second: 100 # if (not first) (not or) (not second): 101 # if not (first or second): 102 # return False 103 # else: 104 # return True 105 return not (not (first or second))still green.
I remove
not not94def logical_disjunction(first, second): 95 # if (first, second) == (False, False): return False 96 # return first, second 97 # if first == False and second == False: 98 # if not first == True and not second == True: 99 # if not first and not second: 100 # if (not first) (not or) (not second): 101 # if not (first or second): 102 # return False 103 # else: 104 # return True 105 # return not (not (first or second)) 106 return first or secondthe test is still green.
I remove the commented lines from logical_disjunction
94def logical_disjunction(first, second): 95 return first or second 96 97 98def logical_conjunction(first, second): 99 return first and second
I break up the if statements in logical_equality
88def logical_equality(first, second): 89 # if (first, second) == (True, False): return False 90 # if (first, second) == (False, True): return False 91 # return first, second 92 if first == True and second == False: 93 return False 94 if first == False and second == True: 95 return False 96 return Truethe test is still green.
I change the if statements with not and True
88def logical_equality(first, second): 89 # if (first, second) == (True, False): return False 90 # if (first, second) == (False, True): return False 91 # return first, second 92 # if first == True and second == False: 93 if first == True and not second == True: 94 return False 95 # if first == False and second == True: 96 if not first == True and second == True: 97 return False 98 return Truestill green.
I remove
== True88def logical_equality(first, second): 89 # if (first, second) == (True, False): return False 90 # if (first, second) == (False, True): return False 91 # return first, second 92 # if first == True and second == False: 93 # if first == True and not second == True: 94 if first and not second: 95 return False 96 # if first == False and second == True: 97 # if not first == True and second == True: 98 if not first and second: 99 return False 100 return Truegreen.
I put the two if statements together as one
88def logical_equality(first, second): 89 # if (first, second) == (True, False): return False 90 # if (first, second) == (False, True): return False 91 # return first, second 92 # if first == True and second == False: 93 # if first == True and not second == True: 94 # if first and not second: 95 # return False 96 # if first == False and second == True: 97 # if not first == True and second == True: 98 # if not first and second: 99 if ( 100 (first and not second) 101 or 102 (not first and second) 103 ): 104 return False 105 return Truestill green.
I add a return statement because …
88def logical_equality(first, second): 89 # if (first, second) == (True, False): return False 90 # if (first, second) == (False, True): return False 91 # return first, second 92 # if first == True and second == False: 93 # if first == True and not second == True: 94 # if first and not second: 95 # return False 96 # if first == False and second == True: 97 # if not first == True and second == True: 98 # if not first and second: 99 # if ( 100 # (first and not second) 101 # or 102 # (not first and second) 103 # ): 104 # return False 105 # return True 106 return not ( 107 (first and not second) 108 or 109 (not first and second) 110 )the test is still green.
I multiply not by all the symbols in parentheses
88def logical_equality(first, second): 89 # if (first, second) == (True, False): return False 90 # if (first, second) == (False, True): return False 91 # return first, second 92 # if first == True and second == False: 93 # if first == True and not second == True: 94 # if first and not second: 95 # return False 96 # if first == False and second == True: 97 # if not first == True and second == True: 98 # if not first and second: 99 # if ( 100 # (first and not second) 101 # or 102 # (not first and second) 103 # ): 104 # return False 105 # return True 106 # return not ( 107 # (first and not second) 108 # or 109 # (not first and second) 110 # ) 111 return ( 112 (not (first and not second)) 113 (not or) 114 (not (not first and second)) 115 )the terminal is my friend, and shows SyntaxError
SyntaxError: invalid syntaxI change
not orto and111 return ( 112 (not (first and not second)) 113 # (not or) 114 and 115 (not (not first and second)) 116 )the test is green again.
I multiply not by the symbols in the first part of the statement
111 return ( 112 # (not (first and not second)) 113 ((not first) (not and) (not not second)) 114 # (not or) 115 and 116 (not (not first and second)) 117 )the terminal is my friend, and shows SyntaxError
SyntaxError: invalid syntaxI change
not andto or111 return ( 112 # (not (first and not second)) 113 # ((not first) (not and) (not not second)) 114 ((not first) or (not not second)) 115 # (not or) 116 and 117 (not (not first and second)) 118 )the test is green again.
I remove
not not111 return ( 112 # (not (first and not second)) 113 # ((not first) (not and) (not not second)) 114 # ((not first) or (not not second)) 115 (not first or second) 116 # (not or) 117 and 118 (not (not first and second)) 119 )still green.
I multiply not by the symbols in the second part of the statement
111 return ( 112 # (not (first and not second)) 113 # ((not first) (not and) (not not second)) 114 # ((not first) or (not not second)) 115 (not first or second) 116 # (not or) 117 and 118 # (not (not first and second)) 119 ((not not first) (not and) (not second)) 120 )the terminal is my friend, and shows SyntaxError
SyntaxError: invalid syntaxI change
not andto or111 return ( 112 # (not (first and not second)) 113 # ((not first) (not and) (not not second)) 114 # ((not first) or (not not second)) 115 (not first or second) 116 # (not or) 117 and 118 # (not (not first and second)) 119 # ((not not first) (not and) (not second)) 120 ((not not first) or (not second)) 121 )the test is green again.
I remove
not not111 return ( 112 # (not (first and not second)) 113 # ((not first) (not and) (not not second)) 114 # ((not first) or (not not second)) 115 (not first or second) 116 # (not or) 117 and 118 # (not (not first and second)) 119 # ((not not first) (not and) (not second)) 120 # ((not not first) or (not second)) 121 (first or not second) 122 )the test is still green.
I remove the commented lines from logical_equality
88def logical_equality(first, second): 89 return (not first or second) and (first or not second) 90 91 92def logical_disjunction(first, second): 93 return first or second
I make the if statement in logical_nand simpler
83def logical_nand(first, second): 84 # if (first, second) == (True, True): return False 85 # return first, second 86 if first == True and second == True: 87 return False 88 else: 89 return Truethe test is still green.
I remove
== True83def logical_nand(first, second): 84 # if (first, second) == (True, True): return False 85 # return first, second 86 # if first == True and second == True: 87 if first and second: 88 return False 89 else: 90 return Truestill green.
I add a return statement because …
83def logical_nand(first, second): 84 # if (first, second) == (True, True): return False 85 # return first, second 86 # if first == True and second == True: 87 # if first and second: 88 # return False 89 # else: 90 # return True 91 return not (first and second)green.
I remove the commented lines from logical_nand
83def logical_nand(first, second): 84 return not (first and second) 85 86 87def logical_equality(first, second): 88 return (not first or second) and (first or not second)
logical_nor has only one case that returns True. I add an if statement for it
76def logical_nor(first, second): 77 # if (first, second) == (True, True): return False 78 # if (first, second) == (True, False): return False 79 # if (first, second) == (False, True): return False 80 # return first, second 81 if first == False and second == False: 82 return True 83 else: 84 return Falsethe test is still green.
I use not to write the if statement in terms of True
76def logical_nor(first, second): 77 # if (first, second) == (True, True): return False 78 # if (first, second) == (True, False): return False 79 # if (first, second) == (False, True): return False 80 # return first, second 81 # if first == False and second == False: 82 if not first == True and not second == True: 83 return True 84 else: 85 return Falsestill green.
I remove
== True76def logical_nor(first, second): 77 # if (first, second) == (True, True): return False 78 # if (first, second) == (True, False): return False 79 # if (first, second) == (False, True): return False 80 # return first, second 81 # if first == False and second == False: 82 # if not first == True and not second == True: 83 if not first and not second: 84 return True 85 else: 86 return Falsegreen.
I add a return statement
76def logical_nor(first, second): 77 # if (first, second) == (True, True): return False 78 # if (first, second) == (True, False): return False 79 # if (first, second) == (False, True): return False 80 # return first, second 81 # if first == False and second == False: 82 # if not first == True and not second == True: 83 # if not first and not second: 84 # return True 85 # else: 86 # return False 87 return not first and not secondstill green.
I write the statement with not because it happens 2 times
76def logical_nor(first, second): 77 # if (first, second) == (True, True): return False 78 # if (first, second) == (True, False): return False 79 # if (first, second) == (False, True): return False 80 # return first, second 81 # if first == False and second == False: 82 # if not first == True and not second == True: 83 # if not first and not second: 84 # return True 85 # else: 86 # return False 87 # return not first and not second 88 return (not first) (not or) (not second)the terminal is my friend, and shows SyntaxError
SyntaxError: invalid syntaxI factor out not
76def logical_nor(first, second): 77 # if (first, second) == (True, True): return False 78 # if (first, second) == (True, False): return False 79 # if (first, second) == (False, True): return False 80 # return first, second 81 # if first == False and second == False: 82 # if not first == True and not second == True: 83 # if not first and not second: 84 # return True 85 # else: 86 # return False 87 # return not first and not second 88 # return (not first) (not or) (not second) 89 return not (first or second)the test is green again.
I remove the commented lines from logical_nor
76def logical_nor(first, second): 77 return not (first or second) 78 79 80def logical_nand(first, second): 81 return not (first and second)
I add return statement for the if statement of material_implication because
if something: return Falsecan be written asreturn not (something)71def material_implication(first, second): 72 # if (first, second) == (True, False): return False 73 # return first, second 74 return not ((first, second) == (True, False))the test is still green.
I break up the return statement to make it simpler
71def material_implication(first, second): 72 # if (first, second) == (True, False): return False 73 # return first, second 74 # return not ((first, second) == (True, False)) 75 return not (first == True and second == False)still green.
I use not to rewrite it in terms of True
71def material_implication(first, second): 72 # if (first, second) == (True, False): return False 73 # return first, second 74 # return not ((first, second) == (True, False)) 75 # return not (first == True and second == False) 76 return not (first == True and not second == True)green.
I remove
== True71def material_implication(first, second): 72 # if (first, second) == (True, False): return False 73 # return first, second 74 # return not ((first, second) == (True, False)) 75 # return not (first == True and second == False) 76 # return not (first == True and not second == True) 77 return not (first and not second)still green.
I multiply not by everything in parentheses
71def material_implication(first, second): 72 # if (first, second) == (True, False): return False 73 # return first, second 74 # return not ((first, second) == (True, False)) 75 # return not (first == True and second == False) 76 # return not (first == True and not second == True) 77 # return not (first and not second) 78 return (not first) (not and) (not not second)the terminal is my friend, and shows SyntaxError
SyntaxError: invalid syntaxI change
not andto or71def material_implication(first, second): 72 # if (first, second) == (True, False): return False 73 # return first, second 74 # return not ((first, second) == (True, False)) 75 # return not (first == True and second == False) 76 # return not (first == True and not second == True) 77 # return not (first and not second) 78 # return (not first) (not and) (not not second) 79 return (not first) or (not not second)the test is green again.
I remove
not not71def material_implication(first, second): 72 # if (first, second) == (True, False): return False 73 # return first, second 74 # return not ((first, second) == (True, False)) 75 # return not (first == True and second == False) 76 # return not (first == True and not second == True) 77 # return not (first and not second) 78 # return (not first) (not and) (not not second) 79 # return (not first) or (not not second) 80 return not first or secondthe test is still green.
I remove the commented lines from material_implication
71def material_implication(first, second): 72 return not first or second 73 74 75def logical_nor(first, second): 76 return not (first or second)
material_non_implication has 3 cases that return False. I add a return statement for the case that returns True
64def material_non_implication(first, second): 65 # if (first, second) == (True, True): return False 66 # if (first, second) == (False, True): return False 67 # if (first, second) == (False, False): return False 68 # return first, second 69 return (first, second) == (True, False)the test is still green.
I make the return statement simpler
64def material_non_implication(first, second): 65 # if (first, second) == (True, True): return False 66 # if (first, second) == (False, True): return False 67 # if (first, second) == (False, False): return False 68 # return first, second 69 # return (first, second) == (True, False) 70 return first == True and second == Falsestill green.
I use not to write it in terms of True
64def material_non_implication(first, second): 65 # if (first, second) == (True, True): return False 66 # if (first, second) == (False, True): return False 67 # if (first, second) == (False, False): return False 68 # return first, second 69 # return (first, second) == (True, False) 70 # return first == True and second == False 71 return first == True and not second == Truegreen.
I remove
== True64def material_non_implication(first, second): 65 # if (first, second) == (True, True): return False 66 # if (first, second) == (False, True): return False 67 # if (first, second) == (False, False): return False 68 # return first, second 69 # return (first, second) == (True, False) 70 # return first == True and second == False 71 # return first == True and not second == True 72 return first and not secondstill green.
I remove the commented lines from material_non_implication
64def material_non_implication(first, second): 65 return first and not second 66 67 68def material_implication(first, second): 69 return not first or second
firstis True in the two cases where negate_first returns False, I add an if statement for them58def negate_first(first, second): 59 # if (first, second) == (True, True): return False 60 # if (first, second) == (True, False): return False 61 # return first, second 62 if first == True: 63 return False 64 else: 65 return Truethe test is still green.
I add a return statement because …
58def negate_first(first, second): 59 # if (first, second) == (True, True): return False 60 # if (first, second) == (True, False): return False 61 # return first, second 62 # if first == True: 63 # return False 64 # else: 65 # return True 66 return not first == Truestill green.
I remove
== True58def negate_first(first, second): 59 # if (first, second) == (True, True): return False 60 # if (first, second) == (True, False): return False 61 # return first, second 62 # if first == True: 63 # return False 64 # else: 65 # return True 66 # return not first == True 67 return not firstgreen.
I remove the commented lines from negate_first
58def negate_first(first, second): 59 return not first 60 61 62def material_non_implication(first, second): 63 return first and not second
secondis True in the two cases where negate_second returns False. I add an if statement for them52def negate_second(first, second): 53 # if (first, second) == (True, True): return False 54 # if (first, second) == (False, True): return False 55 # return first, second 56 if second == True: 57 return False 58 else: 59 return Truethe test is still green.
I add a return statement because
if something == False:can be written asreturn not something52def negate_second(first, second): 53 # if (first, second) == (True, True): return False 54 # if (first, second) == (False, True): return False 55 # return first, second 56 # if second == True: 57 # return False 58 # else: 59 # return True 60 return not second == Truestill green.
I remove
== True52def negate_second(first, second): 53 # if (first, second) == (True, True): return False 54 # if (first, second) == (False, True): return False 55 # return first, second 56 # if second == True: 57 # return False 58 # else: 59 # return True 60 # return not second == True 61 return not secondgreen.
I remove the commented lines from
truth_table.pybecause all the other functions are already simple1def logical_negation(something): 2 return not something 3 4 5def logical_identity(something): 6 return something 7 8 9def logical_true(): 10 return True 11 12 13def logical_false(): 14 return None 15 16 17def tautology(first, second): 18 return True 19 20 21def project_second(first, second): 22 return second 23 24 25def project_first(first, second): 26 return first 27 28 29def negate_second(first, second): 30 return not second 31 32 33def negate_first(first, second): 34 return not first 35 36 37def material_non_implication(first, second): 38 return first and not second 39 40 41def material_implication(first, second): 42 return not first or second 43 44 45def logical_nor(first, second): 46 return not (first or second) 47 48 49def logical_nand(first, second): 50 return not (first and second) 51 52 53def logical_equality(first, second): 54 return (not first or second) and (first or not second) 55 56 57def logical_disjunction(first, second): 58 return first or second 59 60 61def logical_conjunction(first, second): 62 return first and second 63 64 65def exclusive_disjunction(first, second): 66 return (not (first and second)) and (first or second) 67 68 69def converse_non_implication(first, second): 70 return not first and second 71 72 73def converse_implication(first, second): 74 return first or not second 75 76 77def contradiction(first, second): 78 return False
close the project
I close
truth_table.pyI click in the terminal where the tests are running
I 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
I ran tests using booleans which can be False or True, for the operations of the Truth Table from Mathematics
there are two nullary operations, they do not take input and always return the same thing, they are constant
Logical False always returns False
Logical True always returns True
there are two unary operations, they take one input
Logical Identity returns its input as output
Logical Negation returns the negation of its input as output
there are 16 binary operations, they each take 2 inputs, in this case I named the second input
secondand the first onefirst-
always returns False
never returns True
is the Logical Negation (NOT) of Tautology which always returns True
-
returns
first or not secondis the Logical Negation (NOT) of Converse Non-Implication which returns True only if
firstis False andsecondis True
-
returns
not first and secondis the Logical Negation (NOT) of Converse Implication which returns False if
firstis False andsecondis True
-
returns
first != secondreturns True only if
firstandsecondare NOT equalis the Logical Negation (NOT) of Logical Equality which returns True only if
firstandsecondare equal
Logical Conjunction returns
returns
first and secondis the Logical Negation (NOT) of Logical NAND which returns False only if
firstis True andsecondis True
-
returns
first or secondis the Logical Negation (NOT) of Logical NOR which returns True only if
firstis False andsecondis False
-
returns
first == secondreturns True only if
firstandsecondare equalis the Logical Negation (NOT) of Exclusive Disjunction (Exclusive OR) which returns True only if
firstandsecondare NOT equal
-
returns
not (first and second)is the Logical Negation (NOT) of Logical Conjunction (AND) which returns True only if
firstis True andsecondis True
-
returns
not (first or second)is the Logical Negation (NOT) of Logical Disjunction which returns False only if
firstis False andsecondis False
-
returns
not first or secondis the Logical Negation (NOT) of Material Non-Implication which returns True only if
firstis True andsecondis False
-
returns
first and not secondis the Logical Negation (NOT) of Material/Logical Implication which returns False only if
firstis True andsecondis False
-
always returns
not firstreturns True only if
firstis Falseis the Logical Negation (NOT) of Project First which returns True only if
firstis True
-
always returns
not secondreturns True only if
secondis Falseis the Logical Negation (NOT) of Project Second which returns True only if
secondis True
-
always returns
firstreturns True only if
firstis Trueis the Logical Negation (NOT) of Negate First which returns True only if
firstis False
-
always returns
secondreturns True only if
secondis Trueis the Logical Negation (NOT) of Negate Second which returns True only if
secondis False
-
always returns True
never returns False
is the Logical Negation (NOT) of contradiction which always returns False
-
and
All the binary operations 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?
you now know
how to make a Python test driven development environment manually * what causes AssertionError? * how to make functions * what causes AttributeError * how to pass values from tests to functions * what is None and NOT None * what is True and False in Python * how to write programs that make decisions
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.