python逻辑运算符

109 阅读1分钟
a = 0
b = 1
c = 2

# 1. and: 与: 都真才真
print((a < b) and (c > b))  # True
print(a > b and c > b)      # Flase


# 2. or:或 : 一真则真,都假才假
print(a < b or c > b)      # True
print(a > b or c > b)      # True


# 3. not: 非: 取反
print(not False)           #True

print(not c > b)           #Flase

image.png

image.png