Cloud computing Python Automation: An explanation of the operator code:
Logical operators:
The following assumes that the variable A is ten and B is 20:
and
X and Y
Boolean "and"-if x is False,x and y returns FALSE, otherwise it returns the computed value of Y.
(A and B) returns 20.
Or
X or Y
Boolean "or"-if X is non-0, it returns the value of x, otherwise it returns the computed value of Y.
(A or B) returns 10.
Not
Not X
Boolean "Non"-returns False if X is True. If X is False, it returns TRUE.
Not (A and B) returns False
>> 1>2 and 2<3
False
>> 3>2 and 2<3
True
Bitwise operators:
A bitwise operator computes a number as a binary. The bitwise algorithms in Python are as follows:
The variable a in the following table is 60,b 13.
& Bitwise-AND Operator:
The two values that participate in the operation, if two corresponding bits are 1, the result of that bit is 1, otherwise 0
(A & B) Output result 12, binary interpretation: 0000 1100
| Bitwise OR Operator:
As long as the corresponding two binary has one for 1 o'clock, the result bit is 1.
(A | b) output result 61, Binary interpretation: 0011 1101
^ Bitwise XOR OR Operator:
When two corresponding binary differences, the result is 1
(a ^ b) output result 49, binary interpretation: 0011 0001
~ Bitwise INVERSE Operator:
Each bits of the data is reversed, which turns 1 to 0 and 0 to 1
(~a) Output result-61, Binary interpretation: 1100 0011, in the complement form of a signed binary number.
<< left move operator:
The operands of the operands all move left several bits, and the number of digits to the right of "<<" specifies the number of bits moved, and the low is 0.
A << 2 output results 240, binary interpretation: 1111 0000
> Right Move Operator:
Move all the binary of the left operand of ">>" to the right of several bits
">>" the number to the right specifies the number of bits moved, the high 0, the low discard
A >> 2 output results 15, binary interpretation: 0000 1111
Note: There is a problem in the calculation results, do not change the picture, according to the actual results to
Member operators:
In addition to some of the above operators, Python also supports member operators, which contain a series of members, including strings, lists, or tuples.
Inch
Returns False if the value found in the specified sequence returns True.
x in the y sequence, if X returns True in the y sequence.
Not in
Returns True if no value is found in the specified sequence, otherwise False.
X is not in the Y sequence if x does not return True in the y sequence.
Identity operator:
The identity operator is used to compare the storage units of two objects
Is
is to determine whether two identifiers are referenced from an object
X is y, if ID (x) equals ID (y), is returns result 1
is not
Is does not determine whether two identifiers are referenced from different objects
X is not y if the ID (x) does not equal the ID (y). is not returning result 1
Operator Precedence:
The following table lists all the operators from highest to lowest priority:
**
Index (highest priority)
~ + -
Bitwise flip, unary Plus and minus (the last two methods are called [email protected] and [email protected])
Addition subtraction
> <<
Shift right, left shift operator
&
Bit ' and '
^
Bitwise operators
<= < > >=
Comparison operators
<> = = =
equals operator
= %= /= //= -= += *= **=
Assignment operators
Is isn't
Identity operator
In No in
Member operators
Not OR and
logical operators
Besides, there is one operator. Lowest precedence: Lambada
Cloud computing Python Automation: An explanation of operator code