Boolean operators

I am having difficulties understanding booleans.

Specifically this

I’m not even quite sure how to word my question other then this is not clicking, im not sure how they got true from : True or not False and False

can anyone help me?

It is described above, but a quick review of operator precedence will fill in the holes.

http://www.mathcs.emory.edu/~valerie/courses/fall10/155/resources/op_precedence.html

Notice that not has higher precedence than and, and and has higher precedence than or. That is why we start with not, then and and finally or.

True or not False and False
        ^^^^^^^^^
           True
            /
           /
True or True and False
        ^^^^^^^^^^^^^^
             False
             /
            /
True or False  =>  True
2 Likes

hmmm okay yes this is making a little more sense.

so as I have learned not False = true

so True and False = False? because and checks if both statements are true? and its obviously not because we have true and false, not just true and true?

and how did you get true or false => true ? because its not false or false?

sorry if i am rambling for some reason this is confusing me! Thank you Sir!

Correct; and, not True == False

Correct

In an or expression, only one operand needs to be True for the whole thing to be true. Read up on short-circuiting.

1 Like

Thank you so much!!!

1 Like