[Tutor] Boolean question

Donald Bedsole drbedsole at gmail.com
Wed Mar 16 07:24:49 CET 2011


Hi Jack,

On Wed, Mar 16, 2011 at 1:50 AM, Jack Trades <jacktradespublic at gmail.com> wrote:
> On Wed, Mar 16, 2011 at 12:22 AM, Donald Bedsole <drbedsole at gmail.com>
> wrote:
>
>> not (False and True)
>>
>> Python evaluates it as "True"
>
>
>>
>> 1)You evaluate what's in the parentheses first.  A thing can not be
>> false and true at the same time, so the answer is false.
>
> Yes, the expression in the parenthesis is evaluated first.  However it's not
> just one thing being evaluated.
>
> 'and' evaluates one argument at a time and returns immediately if the
> argument is False.
>
> In this case there are 2 distinct 'things'.  False and True.  False,
> obviously, evaluates to False, which causes 'and' to stop and return False.
> This reduces the expression to...
>
> not False
>
>>
>> 2)However, the "not" outside the parentheses flips the meaning of what
>> is inside the parentheses, so false becomes "True." ?
>
> Correct, the expression "not False" evaluates to True.

Ok, so, as another example:

not(True and False) is "True"

because: the first argument "True" is true, and the second argument
"False" when returned is negated by "not" becomes "not False" which
evaluates to True?


Thanks for the help!  Btw, you're blog looks interesting; I'm going to
have to check it our more closely later.


More information about the Tutor mailing list