Python——逻辑运算(or,and)
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)的更多相关文章
- jave 逻辑运算 vs 位运算 + Python 逻辑运算 vs 位运算
JAVA中&&和&.||和|(短路与和逻辑与.短路或和逻辑或)的区别 博客分类: 面试题目 Java.netBlog 转自 :http://blog.csdn.net/web ...
- python 逻辑运算 ‘and’ ,'or' 在实战中的作用,代替if语句。
彩票程序:课上方法:import random # 生成一个随机两位数 作为一个中奖号码luck_num = random.randint(10,99)print(luck_num)luck_num_ ...
- Python逻辑运算
一.运算符种类 1.比较运算符 > ,< , >= ,<= , != , == 2.赋值运算符 =, +=,-=,*=,/=,**=,%= 3.成员运算符 in not in ...
- python逻辑运算(not,and,or)总结
逻辑运算 1.在没有()的情况下not优先级高于and,and优先级高于or,即优先级关系为()>not>and>or,同一优先级从左往右计算 总结:a or b : 如果a = 0 ...
- 测试误区《二》 python逻辑运算和关系运算优先级
关系运算 关系运算就是对2个对象进行比较,通过比较符判断进行比较,有6种方式. x > y 大于 x >= y 大于等于 x < y 小于 x <= y 小于等于 x = y ...
- python 逻辑运算及奇怪的返回值(not,and,or)
首先,'and'.'or'和'not'的优先级是not>and>or. 同一优先级从左往右计算. 先说非运算,Python的非运算与这些语言相比,并没有特别的地方.not只有两个返回值,T ...
- 01 Python 逻辑运算
#基本运算符 #and or not #优先级 ()>not>and>or #and or not print(2>1 and 1<4 or 2<3 and 9&g ...
- Python数据结构与循环语句
# Python数据结构与循环语句: 首先编程是一项技能,类似跑步,期初不必在意细节,能使用起来就行,等学的游刃有余了再回过头来关注细节问题也不迟. 关于买书: 学会python之后,才需要买书 ...
- python 杂项
Python/JS/ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...
随机推荐
- vue 组件通信
组件 组件之间的数据是单向绑定的. 父组件向子组件通信 是通过子组件定义的props属性来实现.通过props定义变量与变量类型和验证方式. props简化定义 在简化定义中,变量是以数组的方式定义. ...
- weblogic Patch
How to Apply WLS Patch on Weblogic Integrated with OEM Getting "Main Thread" Java.lang.Out ...
- iOS----------使用cocoapods遇到的问题
-bash: /usr/local/bin/pod: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby: bad ...
- macos 常用快捷键及操作
通用: 拷贝相当于window下的复制非苹果键盘(command == win option == alt control == ctrl)Command + C 拷贝(Copy)Command + ...
- SQL server 远程连接不成功解决
一直以来打算自己做一个博客网站,前段时间开始准备做了,正好碰上新睿云服务器免费一年的活动,赶紧拿下.装好了sqlserver ,用本地访问没有问题,但是关键是外网访问一直不行找了好多资料最终才搞定.下 ...
- 写入Log错误日志
第一步创建ApplicationLog类 代码: using System;using System.Collections.Generic;using System.Linq;using Syste ...
- c/c++ linux epoll系列2 利用epoll_wait查看是否可以送信
linux epoll系列2 利用epoll_wait查看是否可以送信 write函数本来是非阻塞函数,但是当缓存区被写满后,再往缓存区里写的时候,就必须等待缓存区再次变成可写,所以这是write就变 ...
- Linux/Unix环境下的make命令详解
https://blog.csdn.net/wxqian25/article/details/21226711
- 小小白搭建nextcloud云盘
我是一名linux的小小白,今天就利用自己的所学搭建属于自己的云盘——nextcloud. 本人学生狗,普通的云盘也要几十块钱,既然我们只是拿来搭建巩固自己知识并不做为生产力,我们就用VMware W ...
- 文件操作命令(rename)
Rename 命令: // 描述: 重命名文件或目录. // 语法: rename [<Drive>:][<Path>]<FileName1> <FileNa ...