- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Introduction to Computer Programming.ppt
Program #程序: #Exp3-6.py age=24 subject=计算机 college=非重点 if (age 25 and subject==电子信息工程)\ or (college==重点 and subject==电子信息工程 )\ or (age=28 and subject==计算机): print(“恭喜,你已获得我公司的面试机会!) else: print(“抱歉,你未达到面试要求“) 程序运行结果: 恭喜,你已获得我公司的面试机会! (1)25岁以上,电子信息工程专业毕业生。 (2)重点大学电子信息工程专业毕业生。 (3)28岁以下,计算机专业毕业 满足以上条件之一即可获得面试机会 Think 例题中,作为面试者的条件是在源程序中进行设定的,如何获取求职者三方面的信息呢?可以在程序中设置3个问题:哪所学校毕业?学的专业是什么?求职者的年龄? 1. 毕业的学校是重点院校吗?(1/2): 1.重点 2. 非重点 2.学的专业是什么?(1/2/3): 1.电子信息工程;2.计算 3.其它 3. 你的年龄? 此时程序应如何改动呢? Pythons design of using indentation rather than braces for code block delimitation not only helps to enforce code correctness, but it even aids implicitly in avoiding potential problems in code that is syntactically correct. One of those such problems is the (in)famous dangling else problem, a semantic optical illusion. “Dangling else” avoidance Please draw diagram for those programs. And tell the results of those programs under the balance is negative or positive. Diagram Syntax of elif statement if expression1: expr1_true_suite elif expression2: expr2_true_suite …. elif expressionN: exprN_true_suite else: none_of_the_above_suite elif statement It allows one to check multiple expressions for truth value and execute a block of code as soon as one of the conditions evaluates to true. Like the else, the elif statement is optional. However, unlike else, for which there can be at most one statement, there can be an arbitrary number of elif statements following an if. Block of diagram of elif statement if expression1: expr1_true_suite elif expression2: expr2_true_suite …. elif expressionN: exprN_true_suite else: none_of_the_above_suite arbitrary number of elif 多分支语句 多分支if语句一般形式为: if 表达式1: 语句1 elif 表达式2: 语句2 …… elif 表达式n: 语句n else: 语句n+1 在多分支语句中,若表达式i(i=1, 2, ..., n)为True则执行语句块i,结束;若表达式i为False,则接着判断表达式i+1的值。 [3-5]Grade student achievement by computer (Fail, Pass, intermediate, Good, Excellent). Its criteria for the classification : Fail is less than 60; 60
您可能关注的文档
- G.Z 八十中实验学校 冷轶惠.ppt
- Gates and RunnersChapter 10.ppt
- Gender Statistics at the United States Census Bureau.ppt
- General Biochemistry.ppt
- Geometric Transformation.ppt
- GEPT Speaking Exam Practice全民英检口语.ppt
- Ginomial Theorem.ppt
- GMS服装管理系统.ppt
- Grade 8 Social Studies.ppt
- Grammar A.ppt
- Introduction to Social Analysis Week 6.ppt
- Introduction to Ubuntu.ppt
- Introduction toArtificial Intelligence.ppt
- Introduction toCMOS VLSIDesignLecture 6 Wires.ppt
- IO体系结构虚拟化.ppt
- IO虚拟化(IOV)简介.ppt
- Iron and Steel Manufacture.ppt
- Iron and the Effect of Exercises.ppt
- Iron-catalyzed Cross Coupling reactions From Rust to a .ppt
- ISACA Chicago ChapterDecember 8, 2011.ppt
文档评论(0)