South Plantation High School logo
South Plantation High School · Procedural Programming with Python

Numeric & String Operators

Arithmetic · Concatenation & repetition · Shortcut assignment · Unary vs. binary · Priority & binding · Lesson review

Review the lesson slides, then complete the assignment at the bottom of this page. Your assignment work is saved in this browser on this computer. When you check a task, your name, period, and which tasks are complete are shared with your teacher (your code is not). When you finish, print it or save it as a PDF to turn in.
1 / 17
Lesson Review

Operators: Numbers, Strings & Shortcuts

+-*///%**+="ha" * 3

The symbols that do the work in Python, and the rules Python uses to decide which one goes first.

By the end of this lesson you will be able to:

  • Use the arithmetic operators correctly, and explain the difference between / and //.
  • Join strings with concatenation (+) and repeat them with repetition (*).
  • Simplify code with shortcut assignment operators like +=, -=, and *=.
  • Tell unary operators from binary operators.
  • Use priority (precedence) and binding (left to right or right to left) to predict the result of an expression.
How to use this page: Use Next and Back (or the arrow keys). Change the values in the editors and click Run or Step. Use the expression stepper to watch Python solve an expression one operation at a time.

Words you will hear today

WordWhat it meansExample
operatorA symbol that does a job with values+, //, +=
operandA value an operator works onthe 7 and 2 in 7 + 2
expressionOperators and operands that Python can calculateprice * 2
evaluateTo calculate an expression down to one value7 + 2 evaluates to 9
priority (precedence)Which operator goes first* before +
binding (associativity)The direction to go when operators tieleft to right
  • Arithmetic, string operators, shortcut assignment, unary vs binary, priority and binding.
  • Operator, operand, expression, evaluate, priority, binding.

Operators are the action symbols of Python: plus, minus, times, and a few you may not have seen in math class. Today we look at what each operator does with numbers and with strings, the shortcut way to update a variable, and the rules Python follows when an expression has more than one operator.

Vocabulary

Operators, operands, and expressions

  • An operator is a symbol that does something to values: +, *, //.
  • The values it works on are its operands.
  • Operators and operands together make an expression. Python evaluates (calculates) an expression to get one value.
  7     +     2
  |     |     |
operand operator operand   ->  evaluates to 9
The same symbol can do different jobs. + adds numbers, but it joins strings. * multiplies numbers, but it repeats strings. What happens depends on the types of the operands.
GroupOperatorsThis lesson
Arithmetic+ - * / // % **Math with numbers
String+ *Join and repeat text
Assignment= += -= *= /= //= %= **=Store and update variables
Unary-x +xOne operand
print(7 + 2)          # 9
print("7" + "2")      # 72
print(3 * 4)          # 12
print("ab" * 3)       # ababab

Expressions can be built from other expressions

Python evaluates an expression one operation at a time, replacing each piece with its value until only one value is left:

(7 + 2) * 3
#  = 9 * 3       the parentheses become 9
#  = 27          then multiply

A variable in an expression is replaced by the value it holds. If price is 4, then price * 2 evaluates to 8.

Mixing types

  • int with float: Python turns the int into a float first. 7 + 2.0 is 9.0.
  • number with string: Python will not guess what you meant. 7 + "2" is a TypeError. You must convert one side yourself with int() or str().
  • Operator = the symbol. Operands = the values. Expression = both together.
  • The operand types decide what an operator does.
  • Python replaces one piece at a time until one value is left.
  • int + float gives a float; number + string is an error.

Let's get the vocabulary straight. In seven plus two, the plus sign is the operator and the seven and two are operands. Notice the last examples: the same plus sign gives 9 with numbers but 72 with strings. The type of the operands changes the job.

Arithmetic

The seven arithmetic operators

OperatorNameExampleResult
+Addition7 + 29
-Subtraction7 - 25
*Multiplication7 * 214
/Division7 / 23.5
//Floor division7 // 23
%Remainder (modulo)7 % 21
**Exponent (power)7 ** 249
Type rules: two ints give an int, except /, which always gives a float. If either operand is a float, the result is a float: 7.0 // 2 is 3.0.

Change a and b, then run. Try b = 0 to see which operators cannot divide by zero.

Where each operator shows up in real programs

  • + and -: scores, totals, counting down lives.
  • *: price times quantity, area of a rectangle.
  • /: averages (total / count), unit prices.
  • // and %: splitting things into groups and leftovers (teams, hours and minutes).
  • **: squares and areas, growth like doubling (2 ** days).

Why does / always give a float? So that the answer is always the same type, no matter which numbers you use. If / sometimes gave an int and sometimes a float, your program would behave differently for different inputs. You can always count on / returning a float.

  • + - * / // % **
  • / always gives a float. Any float operand gives a float.
  • / always gives a float so the result type is predictable.

You know the first four from math class. The new ones are floor division with two slashes, remainder with the percent sign, and exponent with two stars. Run the editor with different numbers. Then try b equals zero: Python stops with a ZeroDivisionError as soon as it reaches the first division.

Arithmetic

Division / versus floor division //

  • / is true division. It gives the exact answer as a float, every time, even when it divides evenly: 8 / 2 is 4.0.
  • // is floor division. It divides, then rounds down to the next whole number. With two ints, the result is an int.
a and ba / b givesa // b gives
7 and 23.53
8 and 24.04
-7 and 2-3.5-4
7.0 and 23.53.0
"Round down" means toward negative infinity, not toward zero. -7 // 2 is -4, because -4 is below -3.5. The Python docs say floor division is "mathematical division with the 'floor' function applied to the result."
When to use //: when you need a count of whole groups. 30 students in teams of 4: 30 // 4 is 7 full teams.

A way to picture //

For positive numbers, a // b answers "how many whole times does b fit into a?" 2 fits into 7 three whole times (2, 4, 6) with some left over, so 7 // 2 is 3.

For negatives, picture a number line. -7 / 2 is -3.5, which sits between -4 and -3. Floor division always goes to the left, so the answer is -4.

Not the same as int(): int(-3.5) just chops the decimal off and gives -3. -7 // 2 rounds down and gives -4. For positive numbers the two agree, which is why this difference surprises people.

Watch the type: // only gives an int when both operands are ints. 7.0 // 2 rounds down to a whole value, but it is still the float 3.0.

  • / = exact answer, always a float.
  • // = round down; int with two ints. -7 // 2 is -4.
  • a // b: how many whole times b fits into a.
  • int() chops toward 0; // rounds down.

This is the most important difference in today's lesson. One slash always gives you a float with the exact answer. Two slashes give you the whole-number part, rounded down. Be careful with negative numbers: rounding down from negative three and a half gives negative four, not negative three.

Arithmetic

The remainder operator %

a % b gives the remainder left over after dividing a by b. (The % sign is not "percent" here!)

17 // 5  ->  3     (5 goes into 17 three times)
17 % 5   ->  2     (17 = 3 * 5 + 2, so 2 is left over)

Where % is useful

JobCodeExample
Even or odd?n % 2 == 024 % 2 is 0, so 24 is even
Last digitn % 101234 % 10 is 4
Times // 60 and s % 60135 seconds is 2 minutes, 15 seconds
With negative numbers, the result of % takes the sign of the second operand: -7 % 2 is 1, and 7 % -2 is -1.

Enter a number of seconds and run it. // and % work as a team.

Finding a remainder by hand

  1. Find the biggest multiple of the second number that is not more than the first. For 17 % 5: 5, 10, 15, (20 is too big).
  2. Subtract: 17 − 15 = 2.

If the first number is smaller, nothing fits, so the whole thing is left over: 3 % 5 is 3. The remainder is always smaller than the number you divide by, so n % 5 can only be 0, 1, 2, 3, or 4.

More things % is great for

  • Divisible by? n % 3 == 0 is True when n divides evenly by 3.
  • Wrapping around: on a 12-hour clock, 5 hours after 10 o'clock is (10 + 5) % 12, which is 3. % makes numbers "wrap" back to the start, like days of the week.

// and % always fit together: for any numbers, (a // b) * b + (a % b) gives back a. For 17 and 5: 3 × 5 + 2 = 17.

  • % = remainder. Pairs with //.
  • Uses: even/odd, last digit, time and unit conversions.
  • n % b is always 0 up to b - 1.
  • % makes values wrap around, like a clock.

The percent sign in Python does not mean percent. It means remainder, like the R in long division. Floor division tells you how many whole groups, and remainder tells you what is left over. Run the time converter with a few numbers, and try an odd number to see the even or odd check.

Arithmetic

Exponents ** and result types

ExpressionResultWhy
2 ** 1010242 multiplied by itself 10 times
2.0 ** 38.0a float operand gives a float
2 ** -10.5negative exponent: 1 / 2
9 ** 0.53.0power of 0.5 is the square root
Do not use ^ for powers! In Python, ^ is a different operator (bitwise XOR). Use **.
Division by zero stops your program with a ZeroDivisionError, whether you use /, //, or %.

Try these at the prompt:

  • 2 ** 10
  • 9 ** 0.5
  • 10 / 4
  • 10 // 4
  • 10 % 4
  • 0.1 * 3
  • type(8 / 2)
  • 10 / 0

Reading exponent results

  • Whole positive power: repeated multiplication. 3 ** 4 is 3 × 3 × 3 × 3 = 81.
  • Power of 0: any number to the power 0 is 1. 5 ** 0 is 1.
  • Negative power: one divided by the positive power, so the answer is a float. 10 ** -2 is 1 / 100 = 0.01.
  • Fraction power: a root. 9 ** 0.5 is the square root, 3.0.

Python ints never overflow, so huge powers are exact: 2 ** 64 is 18446744073709551616.

Why 0.1 * 3 is not exactly 0.3: floats are stored in binary, and 0.1 cannot be stored perfectly. The tiny error shows up as 0.30000000000000004. Use round(x, 2) when you show results to people.

  • ** is power. ^ is not power.
  • Dividing by zero is an error.
  • x ** 0 is 1. Negative powers give floats.

Two stars means raise to a power. Many students try the caret symbol because calculators use it, but in Python it does something completely different, and you will get a wrong answer with no error. Use the prompt to test each example on the list.

String Operators

Concatenation: joining strings with +

  • Concatenation means joining strings end to end: "Ada" + "Lovelace" is "AdaLovelace".
  • + does not add a space for you. Add one yourself: first + " " + last.
  • Both sides must be strings. "5" + "5" is "55".
String + number is an error:
"Age: " + 15 gives
TypeError: can only concatenate str (not "int") to str
Two ways to fix it
print("Age: " + str(15))   # convert with str()
print("Age:", 15)          # or use a comma in print

A comma in print() is not concatenation. print just prints each value with a space between them.

Building a sentence one piece at a time

name = "Ana"
score = 95
message = name + " scored " + str(score) + " points"
print(message)      # Ana scored 95 points

Each + joins two strings, from left to right. Notice the spaces are inside the quotes (" scored "), because + never adds them for you.

Coming later: f-strings. Python has an easier way to mix text and values: f"{name} scored {score} points". The f before the quote lets you put variables inside curly braces, and they are converted to text automatically.
  • + joins strings. No automatic space.
  • str + int is a TypeError; use str() or a comma in print.
  • Put spaces inside the quotes when you concatenate.

When both operands are strings, plus glues them together. Python does exactly what you say, so if you want a space, you have to add one. The most common error here is mixing a string and a number. Pick the last option in the editor and read the message carefully: it says Python can only concatenate a string to a string.

String Operators

Repetition: repeating strings with *

string * int (or int * string) repeats the string that many times.

ExpressionResult
"ha" * 3"hahaha"
3 * "ha""hahaha" (order does not matter)
"-" * 20"--------------------"
"5" * 3"555" (text, not 15)
"a" * 0 or "a" * -2"" (an empty string)
"a" * 2.5TypeError: can't multiply sequence by non-int of type 'float'
"a" * "b"TypeError: can't multiply sequence by non-int of type 'str'
Only + and * work on strings. "a" - "b" gives TypeError: unsupported operand type(s) for -: 'str' and 'str'.

Pick a pattern and a count, then run it. Repetition is great for drawing lines and simple patterns.

Using repetition with other operators

Priority applies to strings too: * happens before +. So "-" * 3 + "|" is "---" + "|", which is "---|".

An underline that always fits: len() counts the characters in a string, so you can make a line exactly as long as a title:

title = "High Scores"
print(title)
print("=" * len(title))
High Scores
===========

Why must the count be an int? You can repeat something 2 times or 3 times, but "2.5 times" has no clear meaning for text, so Python refuses.

  • str * int repeats. The count must be an int.
  • 0 or negative gives an empty string.
  • "=" * len(title) makes an underline that matches the title.

Multiplying a string by a whole number repeats it. That is handy for making divider lines and patterns. The number has to be an integer: you cannot repeat something two and a half times. Try a count of zero, then a negative count, and see what prints.

Assignment

Shortcut (augmented) assignment operators

Programs often update a variable using its own value: score = score + 5. Python has a shortcut for this:

ShortcutDoes the same asIf x is 10, x becomes
x += 3x = x + 313
x -= 3x = x - 37
x *= 3x = x * 330
x /= 4x = x / 42.5
x //= 4x = x // 42
x %= 4x = x % 42
x **= 2x = x ** 2100
  • They work on strings too: msg += "!" and line *= 3.
  • The variable must already exist. total += 10 before total has a value gives NameError: name 'total' is not defined.
  • PEP 8 style: put one space on each side: count += 1.

Step through and watch score change in the Variables panel. Which line turns it into a float?

Why use the shortcut?

  • Less typing, fewer typos: player_one_score = player_one_score + 1 has two chances to misspell the name. player_one_score += 1 has one.
  • Easier to read: += says "add to this" right away.

Two patterns you will use all the time

count = 0          # a counter starts at 0
count += 1         # ...and goes up by 1 each time something happens

total = 0          # an accumulator starts at 0
total += price     # ...and adds each new value

Both need the starting line first. That is why total += 10 on its own causes a NameError.

  • x op= y means x = x op y.
  • Variable must exist first.
  • Counter: count += 1. Accumulator: total += value.

Updating a variable is so common that Python gives us shortcuts. Plus equals means take the current value, add to it, and store the result back in the same variable. Every arithmetic operator has one. Step through the editor and watch the score. Notice which line changes it from an int to a float.

Assignment

Practice: rewrite with a shortcut

Pick the shortcut that does the same thing as each line, then click Check. Practice only; nothing is recorded.

Trap 1: =+ is not +=
score =+ 5 gives no error. Python reads it as score = +5, so score just becomes 5.
Trap 2: there is no ++
Some languages use x++ to add 1. In Python it is SyntaxError: invalid syntax. Use x += 1.
Trap 3: order matters for - and /
x = 10 - x is not x -= 10. If x is 3, the first gives 7 and the second gives -7.

How to spot a line that can use a shortcut

Look for this shape: the same variable on both sides, and it comes first on the right.

  • lives = lives - 1 → lives -= 1
  • price = price * 2 → price *= 2
  • total = 100 - total → no shortcut, because total is not first on the right.

For + and * with numbers, order does not matter (x = 2 * x is still x *= 2). For -, /, //, %, and **, order matters.

  • Only "x = x op value" becomes "x op= value".
  • =+ is a silent bug. ++ does not exist.

A shortcut only works when the variable appears first on the right side. Then look at the traps. Equals plus is the sneakiest: there is no error, but your score gets replaced instead of increased. And if you come from another language, remember Python has no plus plus.

Unary vs Binary

Unary versus binary operators

  • A binary operator has two operands, one on each side: a - b, a * b.
  • A unary operator has one operand: -b. ("Uni" means one, like a unicycle.)
OperatorUnary exampleBinary example
--x (negative)5 - x (subtract)
++x (same value)5 + x (add)
notnot done (flip True/False)(always unary)
* / // % **(never unary)5 * x
Both at once: in 5 - -3, the first - is binary (subtract) and the second is unary (negative 3). The answer is 8.

Set x, pick an expression, and run it. Can you explain the difference between the last two?

How Python tells them apart

Python looks at what is just before the -:

  • If there is a value (a number, a variable, or a closing parenthesis) to its left, the - is binary: subtract.
  • If there is nothing, or another operator, to its left, it is unary: make negative.

So in 5 - -3, the first - has 5 before it (binary), and the second has - before it (unary). Python reads it as 5 minus (negative 3), which is 8. Adding spaces or parentheses, 5 - (-3), makes it easier for people to read.

Unary minus does not change the variable. -x gives the negative value, but x stays the same unless you store it: x = -x.

  • Binary: two operands. Unary: one operand.
  • - can be either one, depending on what is to its left.
  • -x gives a value; it does not change x unless you assign it.

Python decides whether a minus sign is unary or binary by looking at what is in front of it. If there is a value on its left, it is subtraction. If not, it means negative. Try five minus negative x, and then compare negative x squared with negative x in parentheses squared. Those last two give different answers, and the next slides explain why.

Priority & Binding

Priority: which operator goes first?

When an expression has more than one operator, Python uses priority (also called precedence) to decide the order, just like the order of operations in math.

PriorityOperatorsName
1 (first)( )Parentheses
2**Exponent
3+x -xUnary plus and minus
4* / // %Multiply, divide, floor divide, remainder
5+ -Binary add and subtract
6== != < <= > >=Comparisons
7notLogical not
8andLogical and
9 (last)orLogical or

Simplified from the operator precedence table in the Python Language Reference.

print(2 + 3 * 4)       # 14: * goes before +
print((2 + 3) * 4)     # 20: parentheses first
print(20 - 6 / 2)      # 17.0: / goes before -
print(7 + 8 // 3 % 2)  # 7: // and % before +
print(3 + 4 > 6)       # True: math before comparing
14 20 17.0 7 True
Notice: *, /, //, and % all share the same priority, and so do + and -. When operators tie, the next slide's binding rule decides.
When in doubt, use parentheses. They make the order clear to Python and to anyone reading your code.

Solving one by hand

Take 7 + 8 // 3 % 2. Find the highest-priority operators first:

7 + 8 // 3 % 2
# = 7 + 2 % 2      // and % tie, so go left to right: 8 // 3 is 2
# = 7 + 0          then 2 % 2 is 0
# = 7              + is last

Compare with PEMDAS

Python's order matches the math rule you know: Parentheses, Exponents, Multiplication and Division, Addition and Subtraction. Python just adds // and % to the multiply/divide level. Remember: M and D are the same level (whichever comes first, left to right), and so are A and S.

  • Parentheses, **, unary, * / // %, + -, comparisons, not, and, or.
  • // and % are on the same level as * and /.

This is the order of operations, Python style. Parentheses first, then exponents, then the multiply and divide group, then add and subtract. Notice that floor division and remainder sit in the same group as multiply and divide. Comparisons and the logical operators come after all the math.

Priority & Binding

Binding: left to right or right to left?

Binding (also called associativity) decides the order when operators have the same priority. The Python docs say:

"Operators in the same box group left to right (except for exponentiation and conditional expressions, which group from right to left)."

Most operators bind left to right

10 - 4 - 3      # (10 - 4) - 3 = 3, not 9
100 / 10 / 5    # (100 / 10) / 5 = 2.0
12 // 5 * 2     # (12 // 5) * 2 = 4

** binds right to left

2 ** 3 ** 2     # 2 ** (3 ** 2) = 2 ** 9 = 512
(2 ** 3) ** 2   # 8 ** 2 = 64

** versus unary minus

The docs: the power operator "binds more tightly than unary operators on its left; it binds less tightly than unary operators on its right."

-2 ** 2         # -(2 ** 2) = -4
(-2) ** 2       # 4
2 ** -1         # 2 ** (-1) = 0.5
Watch out: -2 ** 2 is -4, not 4. Use parentheses to square a negative number: (-2) ** 2.

Why does it matter?

For + and *, the order of a tie does not change the answer. For -, /, and // it does: (10 - 4) - 3 is 3, but 10 - (4 - 3) would be 9. Python picks left to right, the same way you read.

Why is ** the exception?

In math, a "tower" of exponents like 232 is worked out from the top down: 32 = 9 first, then 29 = 512. Python follows the same math convention.

The safe rule: if you have to stop and think about the order, add parentheses. They never hurt, and they help everyone who reads the code later.
  • Same priority: left to right.
  • Exception: ** goes right to left, and -2 ** 2 is -4.
  • Ties matter for - / //; ** follows the math "tower" rule.

Priority tells us which group goes first. Binding settles ties inside a group. For almost everything, Python reads left to right, like you read a book. Exponents are the exception: they stack from the top down, so the right-hand power happens first. And a minus sign in front of a power is applied after the power.

Priority & Binding

Expression stepper

Type an expression (or pick an example) and click Solve step by step. The highlighted part is what Python calculates next, and the reason explains why it goes first. Values come from the practice interpreter, so they match Python.

How to practice with the stepper

  1. Write the expression on paper and underline the operation you think goes first.
  2. Click to reveal the next step. Did you pick the same part?
  3. If not, read the reason it gives (priority or binding) and look at the table on the previous slides.
  4. Try making up your own expressions with a mix of **, -, and parentheses. Those are where most mistakes happen.
  • Python works on one operation at a time: priority first, then binding.
  • Predict each step before you reveal it.

Before you click, predict the answer. Then use Next step to check your thinking one operation at a time. Try two to the three to the two, then negative two squared, and then make up your own. Can you write an expression that comes out to exactly 100 using four different operators?

Debugging

Common mistakes

MistakeCodeWhat happens (Python 3.13)Fix
Expecting a whole number from /7 / 2No error. The result is 3.57 // 2
Thinking // rounds toward zero-7 // 2No error. The result is -4Remember: it rounds down
Forgetting priority2 + 3 * 4No error. The result is 14, not 20(2 + 3) * 4
Squaring a negative-2 ** 2No error. The result is -4(-2) ** 2
String + number"Age: " + 15TypeError: can only concatenate str (not "int") to str"Age: " + str(15)
Repeating by a float"Hi" * 2.5TypeError: can't multiply sequence by non-int of type 'float'Use an int
Backwards shortcutx =+ 5No error. x becomes 5x += 5
Using ++x++SyntaxError: invalid syntaxx += 1
Updating a variable that does not existtotal += 10NameError: name 'total' is not definedtotal = 0 first
Dividing by zero10 / 0ZeroDivisionError: division by zeroCheck the divisor first

Test some of these yourself:

  • -7 // 2
  • -2 ** 2
  • "Age: " + 15
  • x = 10 then x =+ 5 then x
  • x++
  • total += 10

Why the "no error" bugs are the dangerous ones

When Python shows an error, you know something is wrong. But 2 + 3 * 4, -2 ** 2, and x =+ 5 run perfectly and give a wrong answer for what you meant. The only way to catch these is to test with numbers you can check by hand.

A testing habit: before you trust a formula, try it with small, easy numbers where you already know the answer. If the average of 2 and 4 does not come out as 3, check your parentheses: (a + b) / 2, not a + b / 2.
  • Half of these give no error: the program just computes the wrong value.
  • Test formulas with easy numbers you can check by hand.

Look at how many of these mistakes give no error at all. Python happily computes the wrong answer, because it is doing exactly what the code says. That is why knowing the rules for division, priority, and shortcuts matters: Python will not warn you.

Practice

Check yourself

Choose an answer, then click Check. This is practice only. Nothing is graded or recorded.

For every expression question:
  • Find the operator with the highest priority and do it first.
  • If two operators tie, go left to right (except **).
  • Check the type of the answer: does it have a / or a float in it? Then the result is a float.
  • Work out priority first, then binding.

For each expression, find the operator with the highest priority first. If two have the same priority, go left to right, unless they are exponents.

Summary

Cheat sheet

Arithmetic

7 + 2    # 9
7 - 2    # 5
7 * 2    # 14
7 / 2    # 3.5 (always float)
7 // 2   # 3   (round down)
7 % 2    # 1   (remainder)
7 ** 2   # 49  (power)

Strings and shortcuts

"Ada" + " " + "L"  # 'Ada L'
"ha" * 3           # 'hahaha'
"Age: " + str(15)  # 'Age: 15'

x += 1   # x = x + 1
x -= 1   # x = x - 1
x *= 2   # x = x * 2

Priority and binding

  1. ( )
  2. ** (right to left)
  3. unary -x +x
  4. * / // %
  5. + -
  6. comparisons, then not, and, or

Same priority: left to right (except **).

Before you run, check:

  • Did you want / (exact, float) or // (whole groups)?
  • Are both sides of + the same type (both numbers or both strings)?
  • Is the shortcut written +=, not =+?
  • Would parentheses make the order clearer?

Key words to know

operator · operand · expression · true division (/) · floor division (//) · remainder / modulo (%) · concatenation · repetition · augmented assignment (+=) · unary / binary · priority · binding

  • Seven arithmetic operators, two string operators, shortcut assignment, priority and binding.
  • Know the key words: operand, floor division, modulo, concatenation, priority, binding.

Let's wrap up. Know your seven arithmetic operators, especially the difference between one slash and two. Plus and times also work on strings. Shortcuts like plus equals make updating variables quick. And when an expression gets complicated, Python follows priority and binding rules, but you can always add parentheses to make your meaning clear.