python中的邏輯關系


邏輯術語

  在python中會使用下面的術語(字符或者是詞匯)來定義事物的真(True)或者假(False)。計算機的邏輯就是在程序的某個位置檢查這些字符或者變量組合在一起的表達式。

  • and : 與
  • or : 或
  • not : 非
  • != : 不等於
  • == : 等於
  • >= : 大於等於
  • <= : 小於等於
  • True : 真
  • False :假

真值表

  使用各類字符的真值表

not

  • not False  ---    True
  • not True       ---    False

or

  • True or False    ---    True
  • True or True     ---    True
  • False or True    ---    True
  • False or False   ---    False

and

  • True and False    ---    False
  • True and True     ---    True
  • False and True    ---    False
  • False and False   ---    False

not or

  • not (True or False)    ---    False
  • not (True or true)      ---    False
  • not (False or True)    ---    False
  • not (False or False)   ---     True

not and

  • not (True and False)    ---    True
  • not (True and True)    ---    False
  • not (False and True)    ---    True
  • not (False and False)   ---    True

!=

  • 1 != 0    ---    True
  • 1 != 1     ---    False
  • 0 != 1    ---    True
  • 0 != 0    ---    False

==

  • 1 == 0   ---    False
  • 1 == 1    ---    True
  • 0 == 1   ---    False
  • 0 == 0   ---    True


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM