Common operators of python operators and the order of precedence of operators

Python operator list

  1. Python contains a total of seven operator classifications
 2. 算术运算
 3. 赋值运算
 4. 比较(关系运算)
 5. 逻辑运算
 6. 身份运算
 7. 成员运算
 8. 位运算(二进制)

Watermark

a = 21
b = 10
c = 0

c = a + b
print ("1 - c 的值为:", c)

c = a - b
print ("2 - c 的值为:", c)

c = a * b
print ("3 - c 的值为:", c) 

c = a / b
print ("4 - c 的值为:", c)

c = a % b
print ("5 - c 的值为:", c)

# 修改变量 a 、b 、c
a = 2
b = 3
c = a**b 
print ("6 - c 的值为:", c)
 
a = 10
b = 5
c = a//b 
print ("7 - c 的值为:", c)


Next is the priority ordering of arithmetic operators in python

From high to low
5. Power operator **
4. Sign +-3
. Arithmetic operators, such as *, /, //
2. Comparison operators <,<=,>,>=,== ,!=
1. Logical relational operators not, and, or

Guess you like

Origin blog.csdn.net/h123456789999999/article/details/113054799