1. What Is a Variable?

a = 2

a
## 2

2. Variable Assignment

a = 2
b = a

b
## 2
a == b
## True

3. Binary Operators & Comparisons

Operation Description
a + b Add a and b
a - b Substract b from a
a * b Multiply a by b
a / b Divide a by b
a // b Floor-divide a by b, dropping any fractional remainder
a ** b Raise a to the b power
a & b True if both a and b are True; for integers, take the bitwise AND
a | b True if either a or b is True; for integers, take the bitwise OR
a ^ b True if a is True or b is True, BUT NOT BOTH; for integers, take the bitwise EXCLUSIVE-OR
a == b True if a equals b
a != b True if a is not equal to b
a <= b, a < b True if a is less than (less than or equal) to b
a >= b, a > b True if a is greater than (greater than or equal) to b
a is b True if a and b reference the same Python object
a is not b True if a and b reference different Python objects
a = [1, 2, 3]
b = a
c = list(a)
a is b
## True
a is c
## False
a == c
## True

Exercise

What are the results of the following commands?

a = True
b = False
a & b
a | b
a ^ b
a == b
a != b

Open your Jupyter Notebook to test them out!