#python连载第11篇 if 语句
#if单个选择测试,两个print是一个代码块,所以都要执行
age = 17
if age > 10:print("you are old enough to enjoy love with TA")print("you can do some wonderful things")#if一个测试,多个选择语句例子
age = 150
if age < 50:print("the train ticket is free")
elif age == 50:print("the train ticket is free")
elif age < 120:print("the train ticket is half price")
elif age == 120:print("the train ticket is half price")
else:print("the train ticket is full price")     #身高大于120cm,所以全价票
#if 嵌套
num = int(input("please input an integer:"))
if num%5 == 0:if num%6 == 0:print ("the number you input can be exact divided by  5 and 6")else:print ("the number you input can be exact divided by  5,but not by 6")
else:if num%6 == 0:print ("the number you input can be exact divided by  6,but not by 5")else:print  ("the number you input can not be exact divided by 5 and 6")2017-11-26 16:56:48 November Sunday the 47 week, the 330 day
#if的例子,检查字符串
if 'python' == 'Python':print("'python' == 'Python'")
else:print("'python' != 'Python'")       #不相等哈,字母有大小写分别
if 'love' in "I love you":              #in 包含的意思,一个小东西是否在大东西里面print("'love' is in 'I love you'")
else:print("'love' is not in 'I love you'")if 'leben' not in "I love you":         #not in 不包含的意思,小数据是否不在大数据里print("'leben' is not in 'I love you'")
else:print("'leben' is in 'I love you'")
#检查数字:
if 10 <= 6:print("10 <= 6 is true")
else:print("10 <= 6 is false")
#检查多个条件
if 10 > 6 and 10 >9:            #and 代表并且,两个条件都成立才是真print('10 > 6 and 10 >9 is true')
else:print("10 > 6 and 10 >9 is false")if 10 > 6 or 10 < 9:            #or代表或,有一个条件成立就是真print('10 > 6 or 10 >9 is true')
else:print("10 > 6 or 10 >9 is false")

python连载第11篇 if 语句相关推荐

  1. python连载第12篇 for循环 源码+ 答案

    #python连载第12篇 for循环 ''' Python函数 range() 可以自动生成一系列的数字, 但是range()函数本身包含开头数字1,但是不包含末尾数字4 用for循环可以提取产生的 ...

  2. python连载第七篇~python世界里的注释符号

    #小李:Hi,傻瓜计算机,你永远都找不到我在哪里,ははは(仰天大笑出门去),因为我藏在#后面,#比隐身飞机效果还好 ''' 小李:小明啊,看那个德国妞多漂亮!!! 小明:小李,有没有审美情趣,范爷才是 ...

  3. python连载第十五篇~史上最全列表知识源码+答案

    #2017-12-19 19:34:41 December Tuesday the 51 week, the 353 day #python连载第十五篇~list列表#列表定义,访问,索引,操作,切片 ...

  4. 【python小课堂专栏】python小课堂11 - 变量篇

    python小课堂11 - 变量篇 前言 上周偷了点懒,周四到周末断更了,后来思考了下,前一阵儿的更新频率达到了日日更,虽然每章小知识都很详细..但是同学建议进度加快,emmm-然后我决定拉长更新周期 ...

  5. python基础篇{控制流语句}

    控制流语句 条件控制 单条件判断 多条件判断 练习 循环控制 while语句 for语句 range函数 练习 break 和 continue 语句 break语句 continue  python ...

  6. 计算机编程书籍-笨办法学Python 3:基础篇+进阶篇

    编辑推荐: 适读人群 :本书适合所有已经开始使用Python的技术人员,包括初级开发人员和已经升级到Python 3.6版本以上的经验丰富的Python程序员. "笨办法学"系列, ...

  7. python 语言-Python语言的一些基本常用语句

    在学习玩蛇网python教程高级篇之前,大家接触过许多python语句,在本文中我们将Python一些基本的常用语句做了汇总,并简单介绍下这些python常用语句的用途和标准格式,放在一起方便大家参考 ...

  8. python学习[第十三篇] 条件和循环

    python学习[第十三篇] 条件和循环 if语句 单一if 语句 if语句有三个部分构成,关键字if本身,判断结果真假的条件表达式,以及表达式为真或非0是执行的代码 if expression: e ...

  9. 如果你也在学python,准备要学习python,希望这篇文章对你有用。

    如果你也在学python,准备要学习python,希望这篇文章对你有用.虽然有点长,但是建议坚持看完! 首先 建议1.理解Pythonic概念--详见Python中的<Python之禅> ...

最新文章

  1. SpringSecurity使用 配置文件 和wen.xml 文件配置
  2. Java中的JSON
  3. java高级之Io流
  4. 小波的秘密9_图像处理应用:图像增强
  5. Python模块学习——tempfile
  6. Guava 实用操作集合
  7. FPGA双沿采样之Verilog HDL实现
  8. linux安装oracle11g视频,Linux安装oracle11g详细步骤及问题汇总
  9. WIN10关闭Windows Defender
  10. scara机器人动荷载_【机器人在线】SCARA机械结构参数计算说明 下
  11. 基于Qt的连连看小游戏
  12. oppok1掉色吗?_如何对旧的褪色照片进行色彩校正
  13. 李飞飞划重点的「具身智能」,走到哪一步了?
  14. C 语言为什么不会过时?
  15. 使用ajax发送数组请求,Ajax请求传递数组参数
  16. word2013插入excel对象报错_Excel2013中插入对象文件的方法
  17. 前端提效 - js 批量导出 excel 为zip压缩包
  18. 双硫脲改性Zr-MOF吸附材料|聚多巴胺(PDA)改性MOF-5|羧酸改性的UiO-66(Zr)膜|有机骨架材料的定制技术
  19. AVPlayer 本地、网络视频播放相关
  20. 【假期层次晋升计划】四点共圆、托勒密定理——2014年6月25日

热门文章

  1. 【JAVA SE】第九章 接口
  2. Spring-第2天
  3. 面向对象之: 类空间问题及类之间的关系
  4. dp cf 20190614
  5. VS 错误: 未找到与约束contractname Microsoft.VisualStudio.Utilities.IContentTypeRegistryService...
  6. vijos1325 桐桐的糖果计划
  7. 初学网站建设,要学习些什么?
  8. php实现一个简单的购物网站
  9. android Camera 录像时旋转角度
  10. 在winform中,禁止combobox随着鼠标一起滑动!