An expression is the most basic tool for working with numbers
a=1# constant a=a+1# expression
Operator
Operator |
Describe |
Yield |
Generator function Send protocol |
Lambda args:expression |
Generating anonymous functions |
X if y else Z |
Three-dimensional expression |
X or Y |
Logical OR (existence of short-circuit algorithm) |
X and y |
Logic and (existence of short-circuit algorithm) |
Not X |
Logical Non- |
X in Y, x not in Y |
Member relationships |
X is y, X was not y |
Object Entity Testing |
X<y,x<=y,x>y,x>=y,x==y,x!=y |
Compare size |
X|y |
Bit or, set merge set |
X^y |
Bit XOR, set symmetry difference |
X&y |
Bit and, set intersection |
X<<y,x>>y |
Move left or right y position |
X+y,x-y |
Add and subtract, merge delete |
x*y,x%y,x/y,x//y |
Multiply, take the remainder, except, the floor |
-x,+x |
One-dollar subtraction |
~x |
bitwise complement (negation) |
X**y |
Power operation |
X[i] |
Index, Function call |
X[I:J:K] |
Sharding |
X (...) |
Calling functions |
X.attr |
Call Properties |
() |
Tuples, expressions, generators |
[] |
List, list resolution |
{} |
Dictionary, Collection, collection, and dictionary parsing |
3. Priority level
The table above is sorted by priority, the higher the precedence, the same as the priority of the same row
4. If there is a parenthesis in the expression, the parentheses take precedence
(1+2) *31+2*3
5. When the type is mixed, the type is automatically upgraded
Sort from numeric complexity: shaping, floating point, plural
So if the shaping is combined with a floating-point type, the result is a floating-point type
Right here, thank you.
------------------------------------------------------------------
Click to jump 0 basic python-Catalogue
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
0 basic python-5.2 expression operators