Guided Notes

Operators & Conditionals

Arithmetic, assignment, comparison, and logical operators; if/else, the ternary operator, and switch.

Arithmetic and assignment

Slide 1 / 5

Arithmetic: + - * / % (remainder) ** (power), plus ++ and -- to add or subtract 1.

10 % 3 β†’ 1 2 ** 3 β†’ 8

Assignment shortcuts update a variable in place:

score += 10 // score = score + 10 price *= 1.2 count++

Precedence follows maths: * and / before + and -. Use parentheses to be clear: (a + b) * c.

← Variables & Data Types