- Arithmetic operator
+, -,*, / with floating point division, %, ** exponentiated, // divisible. These operators are used on variables of type Number to perform mathematical operations on the variables. + and * can also be used for String, List, and Tuple operations. + merges the contents of two variables. * is the result of repeating the value of a variable a specified number of times.
-
An operator
&If they’re both 1, it’s 1|One of them is one^If inconsistent, the result is 1~According to the not<<We move to the left, we fill in the low 0>>If we move to the right, negative numbers complement by 1, positive numbers complement by 0
&, | ^ ~, < <, > >. These operators can only be used for integer operations, which convert integers into their binary counterparts for bitwise operations.
-
Relational operator
= =! =><> =< =
Used to compare the relationship between two variables of the same type, returning True or False.
-
Logical operator
-
x and y
- if
xforFalse, the result isFalse - if
xFor theFalseReturns a false value ofx - if
xforTrueOr true, returnsyThe value of the
- if
-
x or y
- if
xforTrueOr true, returnsx - if
xforFalseOr false, returnsy
- if
-
not x
- if
xforTrueOr true, returnsFalse - if
xforFalseOr false, returnsTrue
- if
-
Note: bool 0, “, [], {}, (), None is false, all others are considered true.
-
The assignment operator
=+ =- =* =/ =% =* * =/ / =
Used to assign a specific value to a variable, except that = is a direct assignment, all other assignments are incremental. Incrementally assigned variables must be directly assigned before the incrementally assigned operator can be used.
Where += and *= can be used on String, List, and Tuple data types.
- The priority of the operator