Next: Functions for Numeric Data
Up: Types of Numeric Data
Previous: Hexadecimal and Octal Constants
  Contents
Python supports the full set of binary arithmetic operators that you would
expect in a modern computer language. A binary operator is one which performs
an operation on exactly two elements, one on each side of the operator's symbol.
Table 3.1 shows the operators supported by python.
Table 3.1:
Arithmetic Operators
Operator |
Function |
Operator |
Function |
+ |
Addition |
- |
Subtraction |
* |
Multiplication |
/ |
Division |
>> |
Right bit shift |
<< |
Left bit shift |
** |
Exponentiation |
% |
Modulus |
|
When performing operations on integers, be aware that python performs
integer arithmetic unless at least one of the operands is a floating
point number. See Section 3.2 for further information.
In addition to the binary operators in Table 3.1, python also provides
unary operators for plus and minus. Thus any number or expression which returns
a single numeric value can be preceded by either a minus sign (-) or a
plus sign (+).
Next: Functions for Numeric Data
Up: Types of Numeric Data
Previous: Hexadecimal and Octal Constants
  Contents
Phil Spector
2003-11-12