# Python运算符
a = 21
b = 10
c = 0
c += a
print(c)
c *= a
print(c)
c /= a
print(c)
c = 2
c **= 3 # 取c的三次方
print(c)
c = 2
c %= a # 取余
print(c)
c //= a # 向下取整
print(c)
# 位运算
a = 0b00111100
b = 0b00001101
print(a & b) # 按位与运算
print(a | b) # 按位或运算
print(a ^ b) # 异或运算
print(~a) # 按位取反
# 逻辑运算符
a = 1
b = 0
if a and b:
print("a and b is true")
else:
print("a and b is not all true")
if a or b:
print("a or b is true")
else:
print("a and b all flase")
if not(a or b):
print("a and b all flase")
else:
print("a or b is true")
# 成员运算符
a = 1
b = 20
list1 = [1, 2, 3, 4, 5]
if a in list1:
print("a is in list1")
else:
print("a is not in list1")
if b in list1:
print("b is in list1")
else:
print("b is not in list1")
# 获取变量的地址,变量值相同地址相同
print(id(a))
a = 20
b = 20
print(id(a))
print(id(b))
# is 用来判断地址是否相同,引用对象是否相同, == 用来判断变量的值是否相同
if a is b:
print("a and b share the address")
else:
print("a and b do not share the address")
if a is not b:
print("a and b do not share the address")
else:
print("a and share the address")