Data operations and data operators
Arithmetic operators
Arithmetic operators
| Operator |
Describe |
Example |
| + |
Addition |
>>> 14-5 9 |
| - |
Subtraction |
>>> 14-59 |
| * |
Multiplication |
>>> 5 * 1470 |
| / |
Division |
>>> 14/52.8 |
| % |
Modulo, that is, two of the number of quotient of the remainder of the part |
>>> 14% 54 |
| ** |
Power operation |
>>> 2 * * 38 |
| // |
The integer portion of a quotient that returns two numbers. |
>>> 10//33 |
Comparison operators: Comparison operators are not limited to numbers, strings, lists, etc.
comparison Operators
| Operator |
Describe |
Example |
| == |
Determines whether two objects are equal (equal returns TRUE, not equal returns false) |
' ABC ' ' ABC ' True |
| != |
Determines whether an object is not equal (as opposed to = =, returns false for equality, not equal returns True) |
>>> 1! = 2True |
| <> |
Determine if an object is not equal (IBID., but not recommended) |
|
| > |
Determines whether the first object is greater than the second object, greater than return true, not greater than (including equals) returns Fasle |
>>> 3 > 1True |
| < |
Determines whether the first object is less than the second object, is less than the return true, and is not less than (including equals) returned Fasle |
>>> 3 < 4True |
| >= |
Returns True if the first object is greater than or equal to the second object, or False if it is greater than or equal to |
>>> 3 >= 3True |
| <= |
Returns False if the first object is less than or equal to the second object, less than or equal to true. |
>>> 3 <= 4True |
Assignment operators: assigning operations
Assignment operators
| Operator |
Describe |
Example |
| = |
Assign value |
A = C |
| += |
Self-added assignment A + = 1 equivalent to a = a + 1 |
A + = 1 |
| -= |
The self-decrement assignment A-= 1 is equivalent to a = A-1 |
A-= 1 |
| *= |
Squared assignment A *= 1 is equivalent to a = a * 1 |
A *= 1 |
| /= |
A/= 1 equivalent to a = A/1 |
A/= 1 |
| %= |
Pickup mode assignment a%= 1 equivalent to a = a% 1 |
A%= 1 |
| **= |
Self-seeking power assignment a **= 1 is equivalent to a = a * * 1 |
A**= 1 |
| //= |
Self-divisible assignment a//= 1 is equivalent to a = A//1 |
A//= 1 |
Bitwise operators: logical calculations by bits
Bitwise operators
| Operator |
Describe |
Example |
| & |
Bitwise-AND |
>>> 5 & 144 |
| | |
Bitwise OR |
>>> 5 | 1415 |
| ^ |
XOR or |
>>> 5 ^ 1411 |
| << |
Move left |
>>> << 256 |
| >> |
Move right |
>>> >> 23 |
My Python growth path---first day---python Basics (4)---December 26, 2015 (haze)