[Tutor] Logical Operators
alan.gauld at freenet.co.uk
Thu Apr 6 17:53:06 CEST 2006
> I am referring to http://www.ibiblio.org/obp/thinkCSpy/chap04.htm
> about Logical operators
You might find the functional programming topic in my tutorial
interesting for a comparison. Look at the subsection
"Short Circuit Evaluation" for some relevant examples.
> I did not understood
>>> x = 5
>>> x and 1
>>> y = 0
>>> y and 1
> How 5 and 1 means 1 and 0 and 1 means 0
In Python any non zero value is considered True.
So 5 and 1 are two true values and
True and True = True
whereas 0 and 1 means:
False and True = False (ie zero)
Are you familiar with Trutrh tables and the concepts of Boolean Logic?
If not you may need some further explanation. If so a reasonable
explanation appears on Wikipedia:
Author of the learn to program web tutor
More information about the Tutor