Python Operators (Page 1 of 5 )
In the previous two articles on Python, I promised to tell you about Operators, but I lied. Instead I covered such things as conditionals, sets, lists, dictionaries, and so forth. Now, at last, I am going to cover the various operators that Python has to offer, and force you, I mean teach you, to manipulate data with them.
But first, since you've no doubt been busy and the last part of this Python series went live in early December of last year, here is a view of the available operators:
Symbol | Type | What it Does |
+ | Mathematical | Addition |
- | Mathematical | Subtraction |
* | Mathematical | Multiplication |
/ | Mathematical | Division |
// | Mathematical | Truncating Division |
** | Mathematical | Powers |
% | Modulos | Returns the remainder from a division |
<< | Shift | Left Shift |
>> | Shift | Right Shift |
& | Logical | And |
| | Logical | Or |
^ | Logical | Bitwise XOR |
~ | Logical | Bitwise Negation |
< | Comparison | Less than |
> | Comparison | Greater than |
'==' | Comparison | Equal to |
!= | Comparison | Not Equal To |
>= | Comparison | Greater than or Equal To |
<= | Comparison | Less than or Equal To |
'=' | Assignment | Assigns a value |
+= | Assignment | Adds and assigns a value |
-= | Assignment | Subtracts and Assigns a value |
*= | Assignment | Multiplies and assigns a value |
/= | Assignment | Divides and assigns a value |
//= | Assignment | Truncate Divides and assigns a value |
**= | Assignment | Powers and assigns |
%= | Assignment | Modulus and assigns |
>> | Assignment | Shifts and assigns |
<< | Assignment | Shifts and assigns |
And | Boolean |
|
Or | Boolean |
|
Not | Boolean |
|
Next: The Prestigious Mathematical Operators >>
More Python Articles
More By James Payne