# [Edu-sig] Truth values and comparisons

Scott David Daniels Scott.Daniels at Acm.Org
Mon Nov 6 00:42:00 CET 2006

```davelist at mac.com wrote:
> I've not used .any or .all, but having just taught my CS1 students about boolean operators, I was reminded that Python works as the following example describes:
>
> x = a and b
> # if both a and b are true, x is assigned b, otherwise x is assigned a
If a is true, x is assigned b, otherwise x is assigned a:
For example:
x = [1] and ()

> x = a or b
> # if a is true, x is assigned a, if a is true, x is assigned a, if a is false and b is true, x is assigned b, if both a and b are false, x is assigned False
If a is true, x is assigned a, otherwise it is assigned b.
x = () or [1]

Check these out with:
print (() and [], () and [1], (1,) and [], (1,) and [1])
and
print (() or [], () or [1], (1,) or [], (1,) or [1])

Of course these doesn't address Arthur's issues, because Numeric and
friends deal with boolean conversion in an array-processing form.

--Scott David Daniels
Scott.Daniels at Acm.Org

```