# 逻辑运算符 :构造复杂条件
# 优先级  not > and > or
# 逻辑与 and 并且、同时
import random# a = random.randint(1,5)
# if a > 1 and a < 3_流程控制:
#    print("true")
# else:
#     print("false")
# 可以转换为假: '' 0  0. 0 False
# 如果第一个操作数是真,结果就是第二个操作数的值
# print(11 and 'ok')
# 如果第一个操作数是假,结果就是第一个操作数的值
# #如果第一个操作数是假,逻辑不计算第二个操作数的值
# print(0 and 15)# print(0 and False)
# a = 2_运算符和表达式
# (a < 3_流程控制) and exit()
# print("hello")# 逻辑或 or 或者
# 如果第一个操作数为真,结果就是第一个操作数
# print('ok' or 15)
# 如果第一个操作数为假,结果就是第二个操作数的值
# print('' or 10)# 如果逻辑或的第一个操作数为真,不计算第二个操作数,这也是逻辑
# print(1) or print("哈哈哈")
# a = print(1)
# print(a)
#
# 逻辑非 逻辑取反,如果原来是真,结果就是False,否则结果是True
# print(not 10)
# print(not '')# 一、如下是以下值就认为是假
#
#   1、None–>None值
#
#   2_运算符和表达式、False–>False值
#
#   3_流程控制、0 或者0.0 –>数值零不管它是int,float还是complex类型
#
#   4、”,(),[]–>任何一个空的序列
#
#   5、{}–>空的集合。
#   
# 二、所有不满足False条件的值就当成True# 判断闰年:能被4整除 不能被100 或者是能被400整除
year = random.randint(1, 2019)
if (((year % 4) == 0) and (year % 100 != 0)) or (year % 400 == 0):print("%s是闰年" % (year))
else:print("%s不是闰年" % (year))

【python】逻辑运算符总结相关推荐

  1. Python逻辑运算符 and ,or not 的理解

    要理解Python逻辑运算符 and ,or not  这三个 ,你需要知道  在 python里面,0.''.[].().{}.None为 false,其它任何东西都为true 1 and(这个会j ...

  2. Python 逻辑运算符

    Python 逻辑运算符可以用来操作任何类型的表达式,不管表达式是不是 bool 类型:同时,逻辑运算的结果也不一定是 bool 类型,它也可以是任意类型. 这点是和C/C++等语言不同的,C/C++ ...

  3. python逻辑运算符的优先级_Python逻辑运算符

    python逻辑运算符 1.成员 and or not 优先级:() > not > and > or 2.and 逻辑运算符and,a andb,如果a和b都为True,则返回Tr ...

  4. python 逻辑运算符 and or

    https://www.cnblogs.com/white-small/p/6260740.html 1 Python逻辑运算符 Python语言支持逻辑运算符,以下假设变量 a 为 10, b为 2 ...

  5. python 逻辑运算符_Python逻辑运算符

    python 逻辑运算符 Python logical operators allow us to perform logical AND, OR, and NOT operation between ...

  6. Python逻辑运算符

    逻辑运算符用来表示日常生活中"并且"."或者"和"除非"等逻辑关系的运算符. 运算符 含义 说明 and 逻辑与运算,等价于数学中的&quo ...

  7. Python逻辑运算符有哪些?

    Python逻辑运算符中有三种 and . or .not [1]and 逻辑: " 两真为真才是真 "--truetrue and true ---true ---两真为真才是真 ...

  8. python 逻辑运算符_Python关系和逻辑运算符

    python 逻辑运算符 Relation and Logic are the fundamental bricks of a program that defines its functionali ...

  9. Python逻辑运算符优先级小记

    Python逻辑运算符优先级小记

  10. Python逻辑运算符之与或非

    Python逻辑运算符之与或非 一. 短路与(逻辑与)和非短路与 二. python逻辑运算符之与或非 在看python的时候逻辑运算符没看懂. x and y 布尔"与" - 如 ...

最新文章

  1. ORA-01855: AM/A.M. or PM/P.M. required错误解决
  2. 关于临时表和表变量的差别1
  3. [CNT]关于自己的一个小小的slab内存分配器
  4. 玩游戏计算机缺失msvcp140,玩英雄联盟提示电脑缺少msvcp140.dll怎么办
  5. 【渝粤题库】陕西师范大学600007 化工基础 作业(专升本)
  6. kubernetes cpu限制参数说明
  7. 是什么样的骚操作让应用上线节省90%的时间
  8. poi读取合并单元格
  9. 黑盒测试 ------ 等价类划分法
  10. 天下无难试之Redis面试刁难大全「原创」
  11. linux下如何用c语言调用shell命令-转
  12. 携程第二场预赛 1003:位图像素的颜色(水题,判断点是否在矩形内)
  13. 论文笔记_S2D.16-2016-3DV-利用全卷积残差网络进行深度预测
  14. 易语言计算机代码,易语言基础教程之简单代码的编写
  15. MyDiskTest v2.98-U盘扩容检测工具
  16. MAC word2015 插入罗马字母
  17. 「笔耕不辍」mysql的存储引擎详解
  18. flask框架学习笔记
  19. python皮卡丘字符打印代码_皮卡丘第二种
  20. linux下hwclock不能同步时间到硬件时钟

热门文章

  1. H.264解码器ffmpeg完整优化代码(包括PC和Windows Mobile版本)
  2. intellij idea 中去除 @Autowired 注入对象带来的红色下划线报错提示
  3. Linux diffstat命令
  4. Spring-jdbc:JdbcTemplate使用简介
  5. 时间,数字 ,字符串之间的转换
  6. spring IoC/DI
  7. 本地连不上远程mysql数据库(2)
  8. IIS 部署asp.net Core程序注意事项
  9. iOS开发之普通网络异步请求与文件下载方法
  10. Python3 与 C# 并发编程之~ 进程篇