#5.1

major = 'Software Engineering'

print("Is major =='Software Engineering'? I predict True.")print(major=='Software Engineering')print("Is major =='Software Engineering'? I predict False.")print(major=='Computer Science')#5.2

print("--------------------------------------")

string_1='abc'string_2='abc'string_3='abcd'

print("Is string_1==string_2?")print(string_1==string_2)print("Is string_2==string_3?")print(string_2==string_3)print("--------------------------------------")print("Is string_1 == string_1.lower()?")print(string_1==string_1.lower())print("--------------------------------------")print("这个部分实在过于简单和麻烦,略过!")print("--------------------------------------")print(True andFalse)print(True andTrue)print(False andFalse)print(True orFalse)print(True orTrue)print(False orFalse)print("--------------------------------------")

mobileInc= ['apple','xiaomi','huawei','oppo','vivo']print('apple' inmobileInc)print('coolpad' inmobileInc)print('nokia' not inmobileInc)#5.3

alien_color = 'green'

if alien_color == 'green':print("Great!You got 5 point!")

alien_color= 'red'

if alien_color == 'green':print("Great!You got 5 point!")print("------------------------------------")#5.4

alien_color = 'green'

if alien_color == 'green':print("Great!You got 5 point!")else:print("Excellent!You got 10 point!")

alien_color= 'red'

if alien_color == 'green':print("Great!You got 5 point!")else:print("Excellent!You got 10 point!")print("-----------------------------------------")#5.5

alien_color = 'green'

if alien_color == 'green':print("Great!You got 5 point!")elif alien_color == 'yellow':print("Excellent!You got 10 point!")elif alien_color == 'red':print("Oh,my god!You got 15 point!")

alien_color= 'yellow'

if alien_color == 'green':print("Great!You got 5 point!")elif alien_color == 'yellow':print("Excellent!You got 10 point!")elif alien_color == 'red':print("Oh,my god!You got 15 point!")

alien_color= 'red'

if alien_color == 'green':print("Great!You got 5 point!")elif alien_color == 'yellow':print("Excellent!You got 10 point!")elif alien_color == 'red':print("Oh,my god!You got 15 point!")print("-----------------------------------------")#5.6

age = 33

if age < 2:print("婴儿")elif age>=2 and age<4:print("蹒跚学步")elif age>=4 and age<13:print("儿童")elif age>=13 and age<20:print("青少年")elif age>=20 and age<65:print("成年人")elif age>=65:print("老年人")#5.7

favourite_fruits = ['apple','banana','orange']if 'apple' infavourite_fruits:print("You really like apples!")if 'banana' infavourite_fruits:print("You really like bananas!")if 'orange' infavourite_fruits:print("You really like orange!")if 'watermalen' infavourite_fruits:print("You really like watermalen!")if 'grape' infavourite_fruits:print("You really like grape!")

python快速编程入门课后题答案-《Python编程:从入门到实践》第五章 if语句 习题答案...相关推荐

  1. python编程从入门到实践答案-《Python编程:从入门到实践》第五章 if语句 习题答案...

    #5.1 major = 'Software Engineering' print("Is major =='Software Engineering'? I predict True.&q ...

  2. c++primer(第五版) 第十五章 面向对象程序设计习题答案

    纯原创    转载请注明出处:http://blog.csdn.net/axuan_k 略过书上有现成代码的题目 15.1  15.2 15.1 虚成员是基类中的概念 基类中的某些函数希望它的派生类能 ...

  3. 为什么薄膜干涉的厚度要很小_大学物理第五章思考题与习题答案

    问 题 5.1 什么是简谐运动?说明下列运动是否是简谐运动? (1)活塞的往复运动: (2)皮球在硬地上的跳动: (3)一小球在半径很大的光滑凹球面底部的来回滑动,且经过的弧线很短: (4)锥摆的运动 ...

  4. Python编程从入门到实践第五章部分习题

    Python编程从入门到实践第五章部分习题 5-8 5-9` names = ['admin','zhang','li','zhao','song'] for name in names:if nam ...

  5. 《Python从入门到实践》读书笔记——第五章 if语句

    <Python从入门到实践>读书笔记--第五章 if语句 1. 一个简单示例 cars = ['audi', 'bwm', 'subaru', 'toyota']for car in ca ...

  6. 计算机网络第二章物理层部分习题答案

    计算机网络第二章物理层部分习题答案 2-01 物理层要解决哪些问题?物理层的主要特点是什么? 答:物理层要解决的主要问题: (1)物理层要尽可能地屏蔽掉物理设备和传输媒体,通信手段的不同,使数据链路层 ...

  7. 操作系统--第九章 操作系统接口--习题答案

    操作系统第四版课后的全部习题答案,学习通作业答案. 说明:操作系统其他章节的习题答案也在此"操作系统"专栏. 第九章 1.系统安全的复杂性表现在哪几个方面? 答:(1)多面性:大规 ...

  8. 操作系统--第一章 操作系统引论--习题答案

    操作系统第四版课后的全部习题答案,学习通作业答案. 说明:操作系统其他章节的习题答案也在此"操作系统"专栏. 第一章 1.设计现代OS的主要目标是什么?== 答:(1)有效性 (2 ...

  9. [计网:原理与实践] 第五章:端到端协议(课后习题整理)

    第五章 端到端协议 5-1 说明在包括大量应用进程的应用层与支持主机到主机端到端通信的网络层之间设置运输层的必要性.运输层应当提供的服务包括哪些?   运输层运行在位于因特网边缘的端系统上,对上直接为 ...

最新文章

  1. 通知提示SCPromptView
  2. 数学:统计:基本概念
  3. cat命令的13个用法
  4. SQL Server 2000从入门到精通3
  5. java反多态的代码_Java多态性代码详解
  6. DataFrame纵向合并
  7. 2.oracle物理结构,oracle实验2oracle物理结构管理
  8. 23种设计模式之建造者模式
  9. Oracle树查询(查询所有子节点,父节点等等)_转载
  10. Sublime Text 支持GBK , 解决中文乱码问题
  11. .net5 不支持winform_.NET5.0 单文件发布打包操作深度剖析
  12. android刷机工具mac版,苹果一键刷安卓!OS X版CM刷机工具发布
  13. 计算机操作系统-6-并发程序设计
  14. 为什么大多数程序员没有工程思维
  15. 台式计算机规格型号怎么查,台式电脑主板型号在哪里看
  16. 谈谈Java的学习方法
  17. 车载显示屏申请E-mark认证需要测试些什么?
  18. 什么是架构?架构的本质和作用!
  19. PathMeasure 轨迹动画神器 路径动画
  20. 逆天了word 90后:情人节巧用小小技术就俘获了女神

热门文章

  1. java基础面向对象_Java基础面向对象
  2. php适配器模式应用,什么是适配器模式,它有哪些应用场景
  3. Android <java.lang.ClassNotFoundException:Didn‘t find class ‘XXX‘ on path:DexPathList> 解决
  4. DGA域名——可以每天只生成一个域名,因此最多存在365个 DGA域名;
  5. 使用CNN做电影评论的负面检测——本质上感觉和ngram或者LSTM同,因为CNN里图像检测卷积一般是3x3,而文本分类的话是直接是一维的3、4、5...
  6. web前端 —— 移动端知识的一些总结
  7. IR2104s半桥驱动使用经验
  8. Hibernate.Annotation注解
  9. C语言scanf函数详解
  10. Unbalanced calls to begin/end appearance transitions for XXXX