Arithmetic Operators
Python uses the double asterisk (**) as the exponentiation operator instead of superscripts. For example, to raise a number to a power:
Multiplication
To multiply numbers in Python, use the single asterisk (*) operator. The behavior for integers and floating-point numbers follows the same rules:Division
The division operator (/) always returns a floating-point number, even when dividing two integers:Floor Division
If you require an integer quotient when both operands are integers, use the floor division operator (//). This operator returns the quotient rounded toward the lower integer value:Floor division always rounds down to the next lower integer. Positive results round down (e.g., 1.5 to 1.0), while negative results round further away from zero (e.g., -1.5 to -2.0).
Modulo
The modulo operator (%) returns the remainder from a division:Binary vs. Unary Operators
In Python, the plus sign (+) functions as an addition operator and the minus sign (−) serves as a subtraction operator. These are examples of binary operators, where an operator takes two operands (one on the left and one on the right). However, the minus sign can also be a unary operator to indicate a negative number.
Operator Precedence
Operator precedence determines the order in which parts of an expression are evaluated. The rules are as follows:- Unary operators (e.g., the unary minus)
- Exponentiation (**)
- Multiplication, true division (/), floor division (//), and modulo (%)
- Addition and subtraction

- Exponentiation: 6 ** 2 → 36.
- Division and multiplication occur from left to right: 36 / 9 → 4, then 4 * 10 → 40.
- Finally, perform addition and subtraction from left to right: 10 - 40 + 1 → -29.
Sub-Expressions
Sub-expressions, defined by parentheses, override the normal operator precedence rules. Operations within parentheses are computed first. For example:Using parentheses can simplify complex expressions and improve readability within your code.