zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    三、python语法(定义,赋值,注释,输入输出)
    二、Python安装
    一、python简介
    Java第十二天
    Java第十一天
    Java第十天
    Java第九天
    Java第八天
    Java第七天
    Java第六天
  • 原文地址:https://www.cnblogs.com/swearBM/p/11664562.html
Copyright © 2011-2022 走看看