python基础学习(布尔运算符)

  • Post author:
  • Post category:python


基础入门:python中的布尔运算符


源代码:

# 我志在成功 2962909897@qq.com
# 你所经历的所有挫折、失败,
# 甚至那些看似毫无意义消磨时间的事情,
# 都将成为你最宝贵的财富。
# 开发时间:2022/8/18 8:53
#布尔运算符
a,b=1,2
print('-----------------and(并且)----------------')
print(a==1 and b==2)
print(a==1 and b<2)
print(a!=1 and b==2)
print('-----------------or(或者)----------------')
print(a==1 or b==2)
print(a==1 or b<2)
print(a!=1 or b==2)
print(a<1 or b>2)
print('-----------------not(或者)对布尔类型的操作数取反----------------')
f=True
f1=False
print(not f)
print(not f1)
print('-----------------in与not in----------------')
s='hello word'
print('h'in s)
print('j'in s)
print('h'not in s)
print('j'not in s)


源代码运行情况:





版权声明:本文为qq_58866450原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。