版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、Chapter 4 Selections1., , = 2.Yes. i becomes 1, j becomes 0, b1 becomes True, and b2 becomes Flase.3. random.randrange(0, 20) or random.randint(0, 19)4.random.randrange(10, 20) or random.randint(10, 19)5.random.randrange(10, 50 + 1) or random.randint(10, 50)6.random.randrange(0, 2) or random.randint
2、(0, 1) 7.if y 0: x = 18.if score 90: pay *= 1.039.if score 90: pay *= 1.03else: pay *= 1.0110.If number is 30, (a) displays 30 is even30 is odd(b) displays 30 is evenIf number is 35, (a) displays 35 is odd(b) displays 35 is odd11.Note: else matches the second if clause. The output is “x is 3” if x =
3、 3 and y = 2. The output is “z is 7” if if x = 3 and y = 4. No output if if x = 2 and y = 2.12. Note: else matches the first if clause. The output is “x is 2” if x = 2 and y = 4. No output if if x = 3 and y = 2. The output is “z is 6” if if x = 3 and y = 3.13. Consider score is 90, what will be the
4、grade? The conditions are tested in the wrong orders.14. (A) and (C) are equivalent. (B) and (D) are incorrectly indented.15.newLine = (count % 10 = 0)16.Both are correct. (B) is better. Both conditions in (A) are tested. In (B) the condition is tested only once.17.For number is 14, (a) displays:14
5、is even(b) displays14 is evenFor number is 15, (a) displays:15 is multiple of 5(b) displays15 is multiple of 5For number is 30, (a) displays:30 is even30 is multiple of 5(b) displays30 is even18.Yes19.This program will have a runtime error, because tax will not be created.20.(true) and (3 4)Falsenot
6、(x 0) and (x 0)False(x 0) or (x = 0) or (x 1) and (x 1) and (x 100) or (x = y = 0 Falsex = 0Truex!= y = 5True(x != 0) or (x = 0)True 24.Yes 25.If ch is A, the expression is true;If ch is p, the expression is false;If ch is E, the expression is true;If ch is 5, the expression is false;26.(x y and y z
7、) is True(x y or y z) is Truenot (x y) is False(x y z) is Truenot (x y 13 and age 50 or height 160.29.weight 50 and height 160.30.(weight 50 or height 160) and not (weight 50 and height 160) 31.Sorted32. ticketPrice = 20 if (ages = 16) else 10print(count, end = n if count % 10 = 0 else )33.A:if x 10: score = 3 * scaleelse: score = 4 * scaleB:if income 10000: tax = income * 0.2else: tax = income * 0.17 + 1000C:if number % 3 = 0: print(i)else: print(j) 34.The precedence order of the Boolean operators
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 河南省许昌市禹州市2022-2023学年八年级下学期期中英语试题
- 河南省创新发展联盟2023-2024学年高二下学期3月月考英语试题(含答案解析)
- 小学《道德与法治》教研组工作计划
- 一年级培优辅差工作计划
- 土方开挖施工合同
- 二年级上学期语文期末试卷
- 咖啡店会员卡转让人协议
- 出租车行业科技成果
- 湖南省衡阳市耒阳市龙塘中学高一数学文模拟试卷含解析
- 陕西省咸阳市乾县晨光中学高一英语月考试题含解析
- 2024年4月27日江西省考公务员面试真题及答案解析(省市级岗)
- 漏肩风(粘连性肩关节囊炎)中医临床路径及入院标准2020版
- 员工年度综合评价表
- GB∕T 10801.2-2018 绝热用挤塑聚苯乙烯泡沫塑料(XPS)
- 《食品加工新技术》PPT课件.ppt
- 小学生书法艺术欣赏.ppt
- 第二类医疗器械组织机构与部门设置说明
- CUCM配置文档#答案参考
- 待摊费用摊销表模版(带公式版)
- 减轻学生课业负担的几点做法
- 光电成像原理与技术 (白廷柱 著) 北京理工大学出版社 部分习题答案
评论
0/150
提交评论