Operator application in Python programming language is a basic application technology. For beginners, they need to master this application technique to facilitate future application. Here we will take a look at the basic concepts of the Python operator.
Python operator 1) Mixed Mode Operator
Python supports adding different numeric types.
- >>> 20+3.5698
- 23.569800000000001
Python operator 2) standard type operation
- >>> a=1.2
- >>> b=1.20
- >>> a==b
- True
- >>> a>b
- False
- >>> b<b
- False
- >>> a>=b
- True
- >>> a<=b
- True
- >>> (a==b) or(a>=b)
- True
Python Operator 3) Arithmetic Operator
- +,-,*,/,%,**,//
- >>> 7.3/7
- 1.0428571428571429
- >>> 7.3//7
- 1.0
- >>> 4**3
- 64
- >>>
Python Operator 4) bitwise Operator
Bitwise operations only support integers.
Reverse (~), Shifts by bit and (&), or (|), or (^), left (<), and right (> ).
- >>> 4**3
- 64
- >>> 20&35
- 0
- >>> 30&45
- 12
- >>> 30|45
- 63
- >>> 30<<2
- 120
- >>> 30<<2
- 120
- >>> ~30
- -31
- >>> 30 ^ 45
- 51
- >>>
The above is the concept of the Python operator we will introduce in detail.