price = 100
growth_rate = 0.05
name = "portfolio"
price, growth_rate, name(100, 0.05, 'portfolio')
Python is useful for quantitative mathematics because it lets us compute, visualize, and experiment. The first step is understanding how Python stores values.
A variable is a name that points to a value.
Python keeps track of the type of each value.
Common arithmetic operators:
| Operator | Meaning |
|---|---|
+ |
addition |
- |
subtraction |
* |
multiplication |
/ |
division |
** |
exponentiation |
In Python, x = 3 assigns the value 3 to x. It does not mean “prove that x equals 3.”
"100" is text. 100 is a number. They behave differently.
principal with value 250.rate with value 0.08.principal * (1 + rate).describe_value(...) on the result.Answer: principal = 250.
Answer: rate = 0.08.
Answer: 270.0.
The expression is 250 * (1 + 0.08) = 250 * 1.08 = 270.0.