Computer programs consist of instructions that either
- Compute a value
- Perform some action
Instructions that compute values are called expressions. Expressions always return a value. For example, 2 + 3
, add(50, 100)
, "Nestor " + "is a cat"
, 1
, "hello"
and 3.141592653589793
are all expressions (why?).
Instructions that perform actions are called statements. The actions they perform are called "side effects". This nearly always implies some kind interaction with the world outside the program: printing stuff to a terminal screen, fetching data over the internet, or creating and deleting files. Often, but not always, statements return None
(different from the string "None"
). Paradoxically, None
is a value that signifies the quality of not having a value!