Arithmetic operators in Python:
+-*/% *//
Attention:
/: For real division, which corresponds to the division in mathematics, usually returns a floating-point number
: Take the divisible method, namely the pick-up
%: modulo, which takes the remainder
* *: Power operation, one thing to note here is that the power operator precedence is higher than the single-mesh operator on its left, and has a lower precedence than the single-operator on its right.
1 >>> 10/22 5.03 >>>//24 55 >>> 10/36 3.33333333333333357 >>>//38 39 >>> 3Ten 1 One >>>-2 * * 3 A -8 - >>> 2 * *-3 -0.125
View Code
Logical operators:
and (with) or (or) not (non)
1 >>> 1 > 2 or 4 > 3 2 True 3 < and 5 < 44False5>< 2 6True
View Code
Priority level:
- Power Operation * *
- PLUS sign +-
- Arithmetic operator *///
- + -
- Compare operators < <= > >= = = = =
- Logical operator not > and > or
From top to bottom, the priority gradually decreases.
Python Learning Note (vi) operator