[Tutor] The Boolean operator "and"

Alan Gauld alan.gauld at blueyonder.co.uk
Fri Aug 6 20:56:27 CEST 2004


> In the sentence I'm questioning, "Actually, if x is false, it
returns
> x--otherwise it returns y", it seems to me that if x evaluates to
False,
> False is returned, not x itself, (which might be "3 > 4").

The sentence should probably say:

"Actually if *the value of x* is equivalent to False it returns x"

In Python a non zero value is equivalent to True and a zero
(or empty or None) value is False.

This concept of short-circuit evaluation of boolean expressions
is explained in some detail on the functional programming page
of my tutor.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list