+= 加法赋值运算 c +=a 等价于c = c+a
-= 减法赋值运算 c -=a 等价于c = c-a
如a = 10
a += 1 就是a = 10+1 = 11
a -=3 就是a = 10 -3 =7
'''
c =10
c +=1 +2 #解释器先算复合赋值运算右侧的表达式,再算复合赋值运算
# c += 1+2 ---- c += 3
'''
比较运算符==
!= 不等于>大于<
>=
<= 小于等于'''
#逻辑运算符
a =0
b =1
c =2
# 1 and 与 都为真才是真
print(a < band b < c)
print(a < band b > c)
# 2. or 或 一个为真就是 真
print(a >bor c>b)
print(a>bor b>c)
# 3. not 非
print(not a>b)
print(ab)
print((ab))
a =0
b =1
c =2
d =3
#数值复合运算 and 如果有0 ,显示0 否则,结果是最后一个非0数值
# or 如果非0数值,返回第一个非0数值.都为0才返回0
print(aand b)
print(band c)
print(band cand d)
print(aor c)
print(aor bor c)
print(bor cor d)
网友评论