Python orders which operator goes first before others using PEMDAS (Parentheses, Exponentiation, Multiplication and Division, Addition and Subtraction)
Operator | Function | Example Usage | Calculation | Example Output |
---|---|---|---|---|
+ | Addition | 3 + 7 | 3 + 7 | 10 |
- | Subtraction | 3 - 7 | 3 - 7 | -4 |
* | Multiplication | 3 * 7 | 3 x 7 | 21 |
** | To the power of | 3 ** 3 | 33 | 27 |
/ | Division | 11 / 3 | 11 ÷ 3 | 3.66666666667 |
// | Division (Round down) |
11 // 3 | round down 11 ÷ 3 |
3 |
% | Modulus (Remainder) |
11 % 3 | 11 mod 3 | 2 |
Click the triangle button to run the codes and see the output:
Use the operators to solve for the following equations
1. 6 + 4
2. ((27 * 2) + 46) ** 0.5
3. Find the modulus of 35 / 6