运算符 and or not
运算顺序: ()=> not => and =>or
print(3 != 3)
# print(3 <> 3) # 不等于
print(3 >= 2)
a = 10
b = a # 把a的值 赋值给变量b
c = a
print(b)
print(c)
a = 10
b = 20
a += b # a = a + b 累加 sum = sum + count sum += count
print(a) # 30
print(b) # 20
count = 1
while count <= 100:
print(count)
# count = count + 1
count += 1
'''
a+=b a = a + b
a *= b a = a * b
a //= b a = a // b
...
'''
'''
and : 并且. 左右两端同时为真. 结果才能是真
or : 或者. 左右两端有一个是真. 结果就是真
not : 非. 非真既假, 非假既真 不真-> 假 不假 -> 真
'''
print(3 > 2 and 4 < 6 and 5 > 7) # False
print(5 < 6 or 7 > 8 or 9 < 6 or 3 > 2)
print(not 5 < 6)
混合运算
运算顺序: () => not => and => or 当出现相同的运算的时候 从左往右算
print(3 > 2 or 5 < 7 and 6 > 8 or 7 < 5) # True
print(3 > 4 or 4 < 3 and 1 == 1) # False
print(1 < 2 and 3 < 4 or 1 > 2) # True
print(2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # True
print(1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # False
print(1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # False
print((not 2 > 1 and 3 < 4) or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # False
当出现 x or y的时候, 判断x是否是0 如果x==0 then y 否则返回x
print(1 or 2) # 1
print(0 or 2) # 2
print(3 or 0) # 3
print(4 or 0) # 4
print(0 or 3 or 0 or 2 or 0 or 5 or 0 or 188)
当出现 x and y 的时候, 和or相反
print(1 and 2) # 2
print(0 and 3) # 0
print(3 and 0) # 0
print(4 and 0) # 0
print(9 and 3 and 4 and 1 and 4 and 8)
print(1 and 2 or 3) # 应付面试
print(1 and 2 > 4)
False 当成0来看
print(False and 1)
print(3 > 5 or 5 < 6 and 7)
print(4 > 5 or 7 and 8 < 6 or 3 and 4)
成员运算
content = input("请输入你的评论:")
if "马化腾" in content: # content中是否包含了xxx
print("你的评论不合法")
else:
print("你的评论是合法的")
ad = input("请输入你的广告:")
if "最" in ad or "第一" in ad or "全球" in ad:
print("不合法的")
else:
print("合法的")
print(2**32)