🧩Expression
A piece of code that works out to one value, like 3 + 4.
Think of it like
Think of it like a sum on a calculator. You type 3 + 4, and it gives back one answer.
Example
In price * 2, the computer looks up price, doubles it and gets 20. That 20 is the value of the expression.
Why it matters
Most of what a program computes happens inside expressions. Reading them well is reading what the code really does.
Definition
Example code
python
>>> 3 * 4 + 2
14
>>> 10 > 3
TrueCommon mistake
Key takeaways
- 1Gives a value. Every expression works out to one result.
- 2Can nest. Small expressions build bigger ones.
- 3Lives in statements. A statement uses the value it gives.