python脚本编程 lecture 1(课堂ppt) .ppt

  1. 1、本文档共63页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
python脚本编程 lecture 1(课堂ppt) .ppt

Thanks! * * * * * BitTorrent * * * * * * * * * * * * * * * braces 大括号 brackets 方括号 parentheses 圆括号 * * * * * Whitespace Significance Python uses indentation to indicate blocks, instead of {} Makes the code simpler and more readable In Java, indenting is optional. In Python, you must indent. You may use either tabs or spaces, but you must be consistent hello3.py 1 2 3 4 5 6 7 8 # Prints a welcoming message. def hello(): print(Hello, world!) print(How are you?) # main (calls hello twice) hello() hello() Tabs or spaces shell 1 2 3 4 5 6 7 8 9 10 11 12 # Prints a helpful message. def indent_reminder(): ... print(Remember, you must indent!) File stdin, line 2 print(Remember, you must indent!) ^ IndentationError: expected an indented block def indent_reminder(): ... print(Remember, you must indent!) ... indent_reminder() Remember, you must indent! Tabs or spaces shell 1 2 3 4 5 6 7 8 9 10 11 12 # Prints a helpful message. def indententation_errors(): ... print(this was indented using a tab) ... print(this was indented using four spaces) File stdin, line 3 print(this was indented using four spaces) ^ IndentationError: unindent does not match any outer indentation level def indententation_errors(): ... print(this was indented using a tab) ... print(so this must also use a tab) ... def more_indentation_tricks(): ... print(If I use spaces to indent here.) ... print(then I must use spaces to indent here.”) Exercise Rewrite the Figures lecture program in Python. Its output: ______ / \ / \ \ / \______/ \ / \______/ +--------+ ______ / \ / \ | SPAM | \ / \______/ ______ / \ / \ +--------+ Exercise Solution def egg(): top() bottom() print() def cup(): bottom() line() print() def stop(): top() print(| SPAM |”) bottom() print() def hat(): to

文档评论(0)

ucut + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档