Assignment statements in Python are of this form:

variable`=`

expression

A simple example of an assignment statement is
“

”, which associates the number 0 with
`sum` = `0`

.
Or “`sum`

”, which computes the sum of
`y` = `x` + `2`

's current value with 2 and associates the variable
`x`

with the result.`y`

A **variable** is any word you make up, composed of
letters, digits, and underscores, provided it doesn't start with
a digit and it doesn't happen to
conflict with a short list of words special to Python (e.g.,

and **for**

).**if**

An **expression** can be as simple as a number or a
variable, or it can be built up using mathematical operators.
Operators available to us include:

`**`

exponentiation `*`

multiplication `/`

division ( `is 2.667)`

16/6`%`

remainder ( `is 4)`

16%6`//`

integer division, ignoring remainder ( `is 2)`

16//6`+`

addition `-`

subtraction

Operations are done in the same order of operations as in mathematics: Exponentiation comes first, followed by the different multiplication and division options, followed by addition and subtraction. As in mathematics, you can use parentheses to specify a different order. Here are some examples.

y=2*x**2+1Let ybe the result of 2x² + 1

z=1/ (y+1)Let zbe the reciprocal ofy+ 1

w=1/y+1Let wbe the result of adding 1 to the reciprocal ofy

u=x%10Let ube the ones' digit ofx

v= (x%100) //10Let vbe the tens' digit ofx(Parentheses aren't necessary here, but it's easier to read.)

Finally, let me mention one hangup for many beginners. Consider this sequence.

`a` = `2`

`b` = `a` + `1`

`a` = `4`

Obviously, the first statement puts 2 into

,
and the second statement puts 3 into `a`

.
The third statement changes `b`

to 4;
`a`*but *
The value of

`b`

is still 3, and it won't change until
an explicit assignment to `b`

.