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:
You are expected to comply with University policies and guidelines namely, Appropriate Use of Information Resources Policy, IT Usage Policy and Social Media Policy. Users will be personally liable for any infringement of Copyright and Licensing laws. Unless otherwise stated, all guide content is licensed by CC BY-NC 4.0.