02 布尔值计算

# 判断下列逻辑语句的  #True,  #False

# 1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6  # True
# False or True or False and True and True or False
# False or True or True or False
# True
print(1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)

# not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6 # not 最后计算  False
# not True and True or False and True and True or False
# not True or  True or False
# not True
print(not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)

# 求出下列逻辑语句的值。

# 8 or 3 and 4 or 2 and 0 or 9 and 7 # 8
# 8 or 4 or 0 or 7
# 8 or 0 or 7
# 8 or 7
print(8 or 3 and 4 or 2 and 0 or 9 and 7)

# 0 or 2 and 3 and 4 or 6 and 0 or 3 # 4
# 0 or 4 or 0 or 3
#  4 or 3
print(0 or 2 and 3 and 4 or 6 and 0 or 3)
# 下列结果是什么?

# 6 or 2 > 1    # 6
# 6 or True
print(6 or 2 > 1)

# 3 or 2 > 1    # 3
# 3 or True

# 0 or 5 < 4    # False
# 0 or False

# 5 < 4 or 3    #3
# False or 3

# 2 > 1 or 6    # True
# True or 6

# 3 and 2 > 1   # True
# 3 and True

# 0 and 3 > 1 # True
# 0 and True

# 2 > 1 and 3  # 3
# True and 3

# 3 > 1 and 0 # 0
# True and 0

# 3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2  # 2
# True and 2 or True and 3 and 4 or True
# 2 or 4 or True
print(3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2)
posted @ 2024-09-25 21:10  jhchena  阅读(2)  评论(0编辑  收藏  举报