Question: I am confused as to when I should use Boolean vs bitwise operators

* `and` vs `&`
* `or` vs `|`

Could someone enlighten me as to when do i use each and when will using one over the other affect my results?

Answer: 
If you are trying to do element-wise boolean operations in `numpy`, the answer is somewhat different. You can use `&` and `|` for element-wise boolean operations, but `and` and `or` will return value error.

To be on the safe side, you can use the [numpy logic functions](http://docs.scipy.org/doc/numpy/reference/routines.logic.html).

```
np.array([True, False, True]) | np.array([True, False, False])
# array([ True, False,  True], dtype=bool)

np.array([True, False, True]) or np.array([True, False, False])
# ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

np.logical_or(np.array([True, False, True]), np.array([True, False, False]))
# array([ True, False,  True], dtype=bool)

```
Logical Operations
------------------

are usually used for conditional statements. For example:

```
if a==2 and b>10:
    # Do something ...

```

It means if both conditions (`a==2` and `b>10`) are true at the same time then the conditional statement body can be executed.

Bitwise Operations
------------------

are used for data manipulation and extraction. For example, if you want to extract the four LSB (Least Significant Bits) of an integer, you can do this:

```
p & 0xF

```