python学习日记_第十一天(ex27~28)

来源:互联网 发布:李选民淘宝上卖的真吗 编辑:程序博客网 时间:2024/05/01 20:13

习题 27: 记住逻辑关系

需要记忆的逻辑符号,最基础的逻辑。初心者向。

  • and 与
  • or 或
  • not 非
  • != (not equal) 不等于
  • == (equal) 等于
  • >= (greater-than-equal) 大于等于
  • <= (less-than-equal) 小于等于
  • True 真
  • False 假

习题 28: 布尔表达式练习

联系的对于布尔值的判断

# 1 == True; 0 == FalseTrue and True   #1False and True  #01 == 1 and 2 == 1 #0"test" == "test"  #11 == 1 or 2 != 1  #1True and 1 == 1   #1False and 0 != 0  #0True or 1 == 1    #1"test" == "testing" #01 != 0 and 2 == 1 #0"test" != "testing" #1"test" == 1 #0not (True and False) #1not (1 == 1 and 0 != 1) #0not (10 == 1 or 1000 == 1000) #0not (1 != 10 or 3 == 4) #0not ("testing" == "testing" and "Zed" == "Cool Guy") #11 == 1 and not ("testing" == 1 or 1 == 0) #1"chunky" == "bacon" and not (3 == 4 or 3 == 3) #03 == 3 and not ("testing" == "testing" or "Python" == "Fun") #1 -->错了,修正为0
加分项目:     1.Python 里还有很多和 != 、 == 类似的操作符. 试着尽可能多地列出 Python 中的等价运算符。例如 < 或者 <= 就是。     2.写出每一个等价运算符的名称。例如 != 叫 “not equal(不等于)”。     A1&2:            等于 : ==      不等于 : !=     大于 : >     小于 : <     大于等于 : >=     小于等于 : <=     3.在 python 中测试新的布尔操作。在敲回车前你需要喊出它的结果。不要思考,凭自己的第一感就可以了。把表达式和结果用笔写下来再敲回车,最后看自己做对多少,做错多少。
0 0
原创粉丝点击