### Literal

A literal is a constant value for some of the built-in types. Here are some examples of literals.

```>>> a = 1                # 1 is an integer literal
>>> b = 2.3              # 2.3 is a floating point literal
>>> c = False            # False is a boolean literal
>>> d = 5L               # 5L is a long integer literal
>>> e = 8 + 6j           # 8 + 6j  is a complex literal
>>> f = "Hello"          # "Hello" is a string literal
```

### Expression

An expression is composed of variables and operators. The simplest expression is just a variable. The value of an expression is evaluated before it is used.

### Arithmetic Operators

These are the arithmetic operators that operate on numbers (integers or floats). The result of applying an arithmetic operator is a number.

• Subtraction: -
• Multiplication: *
• Division: /
• Remainder: %
• Exponentiation: **

### Comparison Operators

There are 6 comparison operators. The result of applying the comparison operators is a Boolean - True or False.

• Equal to: ==
• Not equal to: !=
• Greater than: >
• Greater than or equal to: >=
• Less than: <
• Less than or equal to: <=

You may apply the comparison operator between two operands like so (a > b). You can also apply the comparison operators in sequence like so (a > b > c). However, this is a practice that is not recommended.

### Boolean Operators

In Python, we have two Boolean literals - True and False. But Python will also regard as False - the number zero (0), an empty string (""), or the reserved word None. All other values are interpreted as True. There are 3 Boolean operators:

• not: unary operator that returns True if the operand is False and vice versa.
• x and y: if x is false, then that value is returned; otherwise y is evaluated and the resulting value is returned.
• x or y: if x is true, then that value is returned; otherwise y is evaluated and the resulting value is returned.

### Truth Table for NOT

 a not a F T T F

### Truth Table for AND

 a b a and b F F F F T F T F F T T T

### Truth Table for OR

 a b a or b F F F F T T T F T T T T

### Bitwise Operators

The bitwise operators include the AND operator &, the OR operator |, the EXCLUSIVE OR operator ^ and the unary NOT operator ~. The bitwise operators applies only to integer types.

### Truth Table for EXCLUSIVE OR

 a b a ^ b 0 0 0 0 1 1 1 0 1 1 1 0

### Shift Operators

Shift operators are applied only to integer types.

• x << k : shift the bits in x, k places to the left. Multiplication by (2 ** k).
• x >> k : shift the bits in x, k places to the right filling in with the highest bit on the left hand side. Division by (2 ** k).

### Evaluation Order

Python evaluates an expression from left to right except for assignment. In an assignment, the right-hand side is evaluated before the left-hand side. Refer to the operator precedence to determine the order in which the operations are performed.