Conditionals And Control Flows

Bob Gailer bgailer at gmail.com
Wed May 4 10:54:03 EDT 2016


On May 4, 2016 10:45 AM, "Cai Gengyang" <gengyangcai at gmail.com> wrote:
>
> I am trying to understand the boolean operator "and" in Python. It is
supposed to return "True" when the expression on both sides of "and" are
true
>
> For instance,
>
> 1 < 3 and 10 < 20 is True --- (because both statements are true)
> 1 < 5 and 5 > 12 is False --- (because both statements are false)
>
> bool_one = False and False --- This should give False because none of the
statements are False
> bool_two = True and False --- This should give False because only 1
statement is True
> bool_three = False and True --- This should give False because only 1
statement is True
> bool_five = True and True --- This should give True because only 1
statement is True
>
> Am I correct ?
Yes. Caveat : python Boolean operators return the value of the last
argument necessary to determine the outcome.
Example :
2 or 3 results in 2
2 and 3 results in 3.
0 and 3 results in 0.

HTH.



More information about the Python-list mailing list