Python Basics

Expressions consist of values (such as 2) and operators (such as +), and they can always evaluate (that is, reduce) down to a single value.

A single value with no operators is also considered an expression, though it evaluates only to itself, as shown here:

2

2

Table 1-1: Math Operators from Highest to Lowest Precedence

Operator

Operation

Example

Evaluates to . . .

**

Exponent

2 ** 3

8

%

Modulus/remainder

22 % 8

6

//

Integer division/floored quotient

22 // 8

2

/

Division

22 / 8

2.75

Multiplication

3 * 5

15

Subtraction

5 - 2

3

Addition

2 + 2

4

Whitespace in between the operators and values doesn’t matter for Python (except for the indentation at the beginning of the line), but a single space is convention