-1

I am new to coding and taking a basic Python course online. The current section I'm on talks about truth tables with Boolean operators. I am following most of it, but there is one part that just doesn't make sense to me no matter how many times I go through it.

This is the table in question

The idea is for each of the numbers 1 - 12 we need to say which results would ultimately be true and which would be false. I am fine with 1-5, 7-8, 10-12, but I keep getting 6 and 9 wrong.

At first I would evaluate the values inside the partenthesis first (for #6 A is True, B is False) and then reverse them with the not so it's (False or True). Since one of them is true I figured the whole thing would be True since it's an "or" but the answer says it's false. The same is the case with #9 just the final result is (True or False) but by following the same logic I would think the overall answer should be true.

I attempted to move on in the course to come back to this later, but the next thing they discussed was the ability to apply the distributive property to these expressions. Using that I went back to the example and came up with the same, apparently incorrect, answers. Viewing the whole statement as "not A or not B" I come to the same conclusion that #6 says "False or True" and #9 says "True or False" both of which seem to be to be True since we're using 'or' not 'and'

Please explain what I am missing here I just can't wrap my head around this. Thanks in advance!

khelwood
  • 55,782
  • 14
  • 81
  • 108
ShaneJ
  • 1
  • 1
  • If `A or B` is true, then `not (A or B)` is false. That is what `not` means. `not (A or B)` is **not the same** as `not A or not B`. – khelwood Jun 22 '21 at 10:02
  • Boolean distributivity also changes the operator. `not (A or B)` is not `(not A) or (not B)`, but `(not A) and (not B)` – Altareos Jun 22 '21 at 10:02
  • oh ok, I missed the part where the or changes to and. Thanks for your help it was driving me nuts! – ShaneJ Jun 22 '21 at 10:06
  • 2
    It doesn't "change to and", any more than -4 changes to 4 in -2 x -4. The principle is called "de Morgan's law". – tripleee Jun 22 '21 at 10:12

1 Answers1

0

If you evaluate the expression inside the parenthesis first you would get a single boolean value then the not operation is done on that value.

Eg:

1

a = True
b = False

print(a or b)

output

True

2

print(not (a or b)) # which is equal to print(not(True))

output

False
Abhi_J
  • 2,061
  • 1
  • 4
  • 16