# [Tutor] mnemonics to better learn Python

Eduardo Vieira eduardo.susan at gmail.com
Fri Jul 31 20:42:58 CEST 2009

```On Fri, Jul 31, 2009 at 12:27 PM, Che M<pine508 at hotmail.com> wrote:
>
>
>> To: tutor at python.org
>> From: alan.gauld at btinternet.com
>> Date: Fri, 31 Jul 2009 17:09:48 +0100
>> Subject: Re: [Tutor] mnemonics to better learn Python
>>
>>
>> "Eduardo Vieira" <eduardo.susan at gmail.com> wrote
>>
>> > Hello, would anybody have a good memorization technique for boolean
>> > results? Like when using 'or'/'and' what it returns when both are
>> > false, the last is false, etc?
>>
>> Hmm, I don't try to remember those, I just work it out based on
>> the meaning.
>>
>> A and B is true only if both A and B are True
>> A or B is true if either A or B is True.
>>
>> Thats it really, what's to remember?
>
> I tend to agree, but since he asked for a mnemonic...
>
> What Python Needs to Return a Boolean
> AND:  Both I demand!
> OR:    One or more.
>
> So,
>
> if A and B are False:
>  [think "Both I demand...are False")
> if A or B are False:
>  [think "One or more...are False")
> if A and B are True:
>  [think "Both I demand...are True")
> etc.
>
> Che
>
>
> ________________________________
> Windows Live™ SkyDrive™: Store, access, and share your photos. See how.
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>
It's not that it's so hard, but I still have to stop and think for a
while... "humm, how's that?"
Like in the IDLE
2 and 4 and 0
Result: 0
2 and 4 and 5
Result: 5
2 and 0 and 6
Result: 0
So, what I need to memorize is that with AND, if there's a false item,
then that false is returned, otherwise the last one is returned
With OR, the first one is returned if true, otherwise, the next "true"
value is returned
2 or 3 or 0
Result: 2
2 or 0 or 3
Result: 2
0 or 2 or 3
Result: 2
0 or '' or 4
Result: 4

Do you see how this can demand a little more of brainwork?

Eduardo
```