[Tutor] Boolean math question

2005-10-22 Thread Joe Bennett
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


0011


In this case the result should be e = 3...


Ideas?



-Joe
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Boolean math question

2005-10-22 Thread Terry Carroll
On Sat, 22 Oct 2005, Joe Bennett wrote:

 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
 
 
 0011 

Use '' rather than AND:

 e = 51  15
 e
3


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Boolean math question

2005-10-22 Thread Danny Yoo


  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
  
  
  0011

 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

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor