9-7-23 Notes
What do programs do?
- Programs work by manipulating values
- Expressions in programs evaluate to values
| Data types | Example Values |
|---|---|
| Integers | 2 44 - 3 |
| Floats | 3.14 4.5 -2.0 |
| Booleans | True False |
| Strings | "HEY" "a" |
Expressions with operators can also be expressed with function call notation
from operator import add
a = 18 + 69
b = add(18 + 69) # these lines will have the same result
pow() is built-in
Anatomy of a Call Expression
add(18, 69)
How Python evaluates a call expression:
- Evaluate the operator
- Evaluate the operands
- Apply the operator (a function) to the operands
Names
- A name can be bound to a value
If you do not put a return statement on your function, you will get None back.
Statements are different from expressions. A statement is executed by the interpreter to perform an action.