zoukankan      html  css  js  c++  java
  • Python学习之[逻辑运算]

    逻辑运算是最基础的技能之一,主要考察我们的逻辑能力:

    首先我们要知道 这三个词的意思 and or not 

    and:并且

    or:或

    not:非真即假,非假即真

    布尔值运算:

    and:两端值都为真,其运算结果为真 如 True and True =True  只要有一个假就为假: True and False=False

    or:两端只要有一个为真就是真 如: True or False=True 只要有一个真就为真

    not True=False, not False=True

    and or not 的运算顺序.

    运算顺序 ()>not>and>or 

    逻辑运算:

    or : 如果两个数字 做逻辑运算 如 x or y. 如果x =0 则结果为y .如果x>0则为x

    and :与or 相反 即可

    练习:

    1)、6 or 2 > 1      6
    2), 3 or 2 > 1 3
    3)、0 or 5 < 4 False
    4)、5 < 4 or 3 3
    5)、2 > 1 or 6 True
    6)、3 and 2 > 1 True
    7)、0 and 3 > 1 0
    8)、2 > 1 and 3 3
    9)、3 > 1 and 0 0
    10)、3 > 1 and 2 or 2 < 3 and 3 and 4 or 3 > 2 2
  • 相关阅读:
    JSONP
    函数式编程
    Cookie
    IE userData
    Web Storage
    前端学PHP之会话Session
    数据结构之归并排序
    数据结构之冒泡排序
    数据结构之插入排序
    数据结构之选择排序
  • 原文地址:https://www.cnblogs.com/charles-lin/p/9588559.html
Copyright © 2011-2022 走看看