zoukankan      html  css  js  c++  java
  • day03 Python 逻辑运算符例题

    1、逻辑运算符

    • or : x or y , x为真,值就是x,x为假,值是y。if x is false then y else x
    • and : x and y, x为真,值是y,x为假,值是x。if x is false then x else y
    • not : x 为真,not x 为假。if x is false then true else false

    注:在没有()的情况下not 优先级⾼高于 and,and优先级⾼高于or,即优先级关系为( )>not>and>or,同⼀一优先级从左往 右计算。

    () > not > and > or

    2、例题 

    1、判断下列列逻辑语句句的True,False.
    
    1 > 1 or 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
    True
    
    not 2 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6
    False
    
    2、求出下列列逻辑语句句的值。
    1),8 or 3 and 4 or 2 and 0 or 9 and 7
    8
    
    2),0 or 2 and 3 and 4 or 6 and 0 or 3
    4
    
    3、下列列结果是什什么?
    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
    

      

  • 相关阅读:
    分布式集群环境下运行Wordcount程序
    VM搭建hadoop分布式集群
    安装运行Hadoop
    网络问题
    Golang依赖工具
    会话进程组终端 · 守护进程
    Golang笔记
    [转]GDB
    [转]用户态与内核态
    【转】linux环境内存分配原理 malloc info
  • 原文地址:https://www.cnblogs.com/fanghongbo/p/9818512.html
Copyright © 2011-2022 走看看