❗

# Expressions in Python

The smallest possible.

If you were to imagine Python to be a universe of its own, an expression would be the atom of this universe. An expression is the atomic unit of expression in Python.

Expressions are representations of value in Python. Something like the expression

`1+2`

represents the value `3`

in Python. Expressions are some combination of values, variables, operators, and function calls. Play around in the Python terminal with me, if you'd like to try a few expressions:>>> 1 + 2

3

>>> 1 - 2

-1

>>> 1/2

0.5

These are different from statements. Statements are a collections of expressions that together "do something". Expressions can be statements, but statements can't be expressions, if that makes any sense. Here's a few examples:

>>> a = 3

>>> a

3

>>> a + 7

4

>>> def f(x):

... return x

>>> f(3)

3

Some of this syntax may not make sense to you — that's okay! Sometimes, a block of these statements do something unique and we wish them special names — like if statements, loops or functions. But the big idea to take away here is that

**everything in Python is a collection of expressions and statements.**Last modified 1yr ago