exercise28 布尔运算练习

Python布尔运算详解与练习
本文介绍了Python中的布尔运算,包括and、or和not的使用。通过一系列的示例,展示了这些运算符如何判断条件真假,并提供了练习题供读者自我检验理解程度。
  1. True and True    true
  2. False and True   false
  3. 1 == 1 and 2 == 1   false
  4. "test" == "test"   true
  5. 1 == 1 or 2 != 1   true
  6. True and 1 == 1    true
  7. False and 0 != 0   false
  8. True or 1 == 1      true
  9. "test" == "testing" false
  10. 1 != 0 and 2 == 1    false
  11. "test" != "testing"  true
  12. "test" == 1          false
  13. not (True and False) true
  14. not (1 == 1 and 0 != 1)  false
  15. not (10 == 1 or 1000 == 1000)   false
  16. not (1 != 10 or 3 == 4)         false
  17. not ("testing" == "testing" and "Zed" == "Cool Guy")   true
  18. 1 == 1 and (not ("testing" == 1 or 1 == 0))            true
  19. "chunky" == "bacon" and (not (3 == 4 or 3 == 3))       false
  20. 3 == 3 and (not ("testing" == "testing" or "Python" == "Fun"))  false
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值