[Tutor] Boolean math question
Danny Yoo
dyoo at hkn.eecs.berkeley.edu
Sun Oct 23 05:25:40 CEST 2005
> > Anyone know of a good explanation of either how to perform boolean
> > math in Python? What I am trying to do is AND two numbers together:
> >
> > e = 51 AND 15
> >
> > 00110011
> > 00001111
> > ------------
> > 00000011
>
> Use '&' rather than "AND":
>
> >>> e = 51 & 15
> >>> e
> 3
For reference, the bitwise boolean operators can be found here:
http://www.python.org/doc/ref/bitwise.html
http://www.python.org/doc/ref/shifting.html
http://www.python.org/doc/ref/unary.html
More information about the Tutor
mailing list