print(0 and 2 > 1) #结果0
print(0 and 2 < 1) #结果0
print(1 and 2 > 1) #结果True
print(1 and 2 < 1) #结果False
print(2 > 1 and 0) #结果0
print(2 < 1 and 0) #结果False
print(2 > 1 and 1) #结果1
print(2 < 1 and 0) #结果False # and 前或后只要有0,都为0
# and 前后都为真,才为真
# and 只要有一个为假,就为假 print(0 or 2 > 1) #结果True
print(0 or 2 < 1) #结果False
print(1 or 2 > 1) #结果1
print(1 or 2 < 1) #结果1
print(2 > 1 or 0) #结果True
print(2 < 1 or 0) #结果0
print(2 > 1 or 1) #结果True
print(2 < 1 or 0) #结果0 # or or前为假,输出or后面
# or or前为真,直接为真

Python——逻辑运算(or,and)的更多相关文章

  1. jave 逻辑运算 vs 位运算 + Python 逻辑运算 vs 位运算

    JAVA中&&和&.||和|(短路与和逻辑与.短路或和逻辑或)的区别 博客分类: 面试题目 Java.netBlog  转自 :http://blog.csdn.net/web ...

  2. python 逻辑运算 ‘and’ ,'or' 在实战中的作用,代替if语句。

    彩票程序:课上方法:import random # 生成一个随机两位数 作为一个中奖号码luck_num = random.randint(10,99)print(luck_num)luck_num_ ...

  3. Python逻辑运算

    一.运算符种类 1.比较运算符 > ,< , >= ,<= , != , == 2.赋值运算符 =, +=,-=,*=,/=,**=,%= 3.成员运算符 in not in ...

  4. python逻辑运算(not,and,or)总结

    逻辑运算 1.在没有()的情况下not优先级高于and,and优先级高于or,即优先级关系为()>not>and>or,同一优先级从左往右计算 总结:a or b : 如果a = 0 ...

  5. 测试误区《二》 python逻辑运算和关系运算优先级

    关系运算 关系运算就是对2个对象进行比较,通过比较符判断进行比较,有6种方式. x > y 大于 x >= y 大于等于 x < y 小于 x <= y 小于等于 x = y ...

  6. python 逻辑运算及奇怪的返回值(not,and,or)

    首先,'and'.'or'和'not'的优先级是not>and>or. 同一优先级从左往右计算. 先说非运算,Python的非运算与这些语言相比,并没有特别的地方.not只有两个返回值,T ...

  7. 01 Python 逻辑运算

    #基本运算符 #and or not #优先级 ()>not>and>or #and or not print(2>1 and 1<4 or 2<3 and 9&g ...

  8. Python数据结构与循环语句

    # Python数据结构与循环语句:   首先编程是一项技能,类似跑步,期初不必在意细节,能使用起来就行,等学的游刃有余了再回过头来关注细节问题也不迟.  关于买书: 学会python之后,才需要买书 ...

  9. python 杂项

        Python/JS/    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...

随机推荐

  1. iOS----------The Apple Developer Program License Agreement has been updated.

    The Apple Developer Program License Agreement has been updated. In order to access certain membershi ...

  2. Fragment与Activity的接口回调

    这里说一个官方推荐的写法: private OnFragmentInteractionListener mListener; @Override public void onAttach(Contex ...

  3. Android项目实战(一): SpannableString与SpannableStringBuilder(转)

    前言: 曾经在一些APP中的一些类似“帮助”“关于”的界面看过一行文字显示不同的颜色的效果,如下效果: 本软件是一款高.大.上的社区类软件. 一般来说,这应该是由一个TextView来显示的,但是自己 ...

  4. 理解java的三种代理模式

    代理模式是什么 代理模式是一种设计模式,简单说即是在不改变源码的情况下,实现对目标对象的功能扩展. 比如有个歌手对象叫Singer,这个对象有一个唱歌方法叫sing(). 1 public class ...

  5. 云服务器挂载/dev/vdb1磁盘

    1.首先检查是否有一块硬盘还未被挂载 2.如图所示,vdb还未被使用,开始分配它吧 [root@localhost ~]# fdisk /dev/vdb Command (m for help): n ...

  6. VS2017在线安装包下载

    VS2017个人免费版即社区官方下载地址为:https://download.microsoft.com/download/D/1/4/D142F7E7-4D7E-4F3B-A399-5BACA91E ...

  7. Python二次编码、小数据池之心照神交

    二次编码.解码.小数据池: encode(str:编码):参数编码方式,返回字节码. str_1 = "编码" str_2 = str_1.encode("utf-8&q ...

  8. SqlSessionFactoryUtil

    private static final String RESOURCE="config.xml"; private static final SqlSessionFactory ...

  9. Saltstack_使用指南06_远程执行-指定目标

    1. 主机规划 Targeting Minions文档 https://docs.saltstack.com/en/latest/contents.html 另请参见:自动化运维神器之saltstac ...

  10. LeetCode算法题-Baseball Game(Java实现)

    这是悦乐书的第288次更新,第305篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第156题(顺位题号是682).你现在是棒球比赛点记录器.给定一个字符串列表,每个字符串 ...