2.4 python common operator
1. arithmetic operation marks
1.1 +, -, *, /
a = 5
b = 5
a = a + 3
b += 3
print(a,b)
operation result:
1.2 +=,*=, -=, /=
a = b = c = d = 10
a += 1
b -= 3
c *= 10
d /= 8
print(a,b,c,d)
operation result:
1.3 // floor division
print("地板除法")
print(10//3)
print(3.0//2) #得到一个最接近除数的数值类型
operation result:
Take the remainder 1.4%
print("取余数")
print(11%2)
print(5%3)
operation result:
1.5 ** exponentiation
print("幂运算")
print(3**3)
operation result:
2. Priority issues
Exponentiation> sign> arithmetic operators> Comparison operators> Logical Operators
Several operators, there is a priority problem
print(-3**2)
print(3**-2)
operation result:
3. Comparison operators
>, >=, <, <=, ==, !=
4. Logical Operators
and, or, not
The result is True / False
print(not 0)
print(not 4)
operation result: