Related:
Examples | += (add assign) + (addition) / (divide) /= (divide assign) - (minus) % (modulo) * (multiply) *= (multiply assign) -= (subtract assign) | Description | Performs the various arithmetic operations on numbers.
The operators with an equals sign will assign the value into the variable name on the left.
Modulo simply returns the remainder after division of two numbers. Eg. 12%10 returns 2 since 10 divides into 12 once with a remainder of 2.
Note: there are no ++ (increment) or --(decrement) operators in Python. | Syntax |
| Parameters |
| Interpreter | Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 10 + 10 20 >>> n = 0 >>> n += 10 >>> n 10 >>> n -=1 >>> n 9 >>> 12%10 2 >>>
|
|
|