title: python逻辑运算符
tags: 笔记
categories: 笔记
author: 喵雨
date: 2022-06-23 10:56:09
coverImg:
'''
逻辑运算符
and or not
and : 与 并且
True and True ---> True
True and False --> False
False and False --> False
False and True --> False
or 或 或者 只要一侧为真,结果即为真
True or False ---> True
True or True --> True
False or False --> False
'''
a = 1
b = 2
print(a and b)
print(b and a) # 两边都是数字,结果是最后得数字值`
c = 0
print(a and c) # and中只要一边为0,那么两边都为0
print(a > c and b > c)
print(a < c and b > c)
print('-' * 30)
print(a > c or b > c)
print(a > c or b < c)
print(a == c or b == c)
print('-'*30)
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。