├── .gitignore ├── Code ├── README.md └── chapter12 │ ├── page15-26 │ └── alien_invasion.py │ ├── page28-29 │ └── alien_invasion.py │ ├── page30-31 │ └── alien_invasion.py │ ├── page33-35 │ ├── alien_invasion.py │ └── settings.py │ └── ship.bmp ├── HTML ├── chapter1.html ├── chapter10.html ├── chapter11.html ├── chapter12.html ├── chapter13.html ├── chapter14.html ├── chapter15.html ├── chapter16.html ├── chapter17.html ├── chapter18.html ├── chapter19.html ├── chapter2.html ├── chapter20.html ├── chapter3.html ├── chapter4.html ├── chapter5.html ├── chapter6.html ├── chapter7.html ├── chapter8.html └── chapter9.html ├── PPT ├── chapter1.pptx ├── chapter10.pptx ├── chapter11.pptx ├── chapter12.pptx ├── chapter13.pptx ├── chapter14.pptx ├── chapter15.pptx ├── chapter16.pptx ├── chapter17.pptx ├── chapter18.pptx ├── chapter19.pptx ├── chapter2.pptx ├── chapter20.pptx ├── chapter3.pptx ├── chapter4.pptx ├── chapter5.pptx ├── chapter6.pptx ├── chapter7.pptx ├── chapter8.pptx └── chapter9.pptx ├── README.md └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | WORKING/ 2 | TODO.md 3 | index.md 4 | main.py 5 | -------------------------------------------------------------------------------- /Code/README.md: -------------------------------------------------------------------------------- 1 | 每一个文件都是完整可运行的代码,文件名对应 PPT 页数。 -------------------------------------------------------------------------------- /Code/chapter12/page15-26/alien_invasion.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import pygame 4 | 5 | 6 | class AlienInvasion: 7 | """管理游戏资源和行为的类""" 8 | 9 | def __init__(self): 10 | """初始化游戏并创建游戏资源""" 11 | pygame.init() 12 | 13 | self.screen = pygame.display.set_mode((1200, 800)) 14 | pygame.display.set_caption("Alien Invasion") 15 | 16 | def run_game(self): 17 | """开始游戏的主循环""" 18 | while True: 19 | # 侦听键盘和鼠标事件 20 | for event in pygame.event.get(): 21 | if event.type == pygame.QUIT: 22 | sys.exit() 23 | # 让最近绘制的屏幕可见 24 | pygame.display.flip() 25 | 26 | 27 | if __name__ == '__main__': 28 | # 创建游戏实例并运行游戏 29 | ai = AlienInvasion() 30 | ai.run_game() 31 | -------------------------------------------------------------------------------- /Code/chapter12/page28-29/alien_invasion.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import pygame 4 | 5 | 6 | class AlienInvasion: 7 | """管理游戏资源和行为的类""" 8 | 9 | def __init__(self): 10 | """初始化游戏并创建游戏资源""" 11 | pygame.init() 12 | 13 | self.clock = pygame.time.Clock() 14 | self.screen = pygame.display.set_mode((1200, 800)) 15 | pygame.display.set_caption("Alien Invasion") 16 | 17 | def run_game(self): 18 | """开始游戏的主循环""" 19 | while True: 20 | # 侦听键盘和鼠标事件 21 | for event in pygame.event.get(): 22 | if event.type == pygame.QUIT: 23 | sys.exit() 24 | # 让最近绘制的屏幕可见 25 | pygame.display.flip() 26 | self.clock.tick(60) 27 | 28 | 29 | if __name__ == '__main__': 30 | # 创建游戏实例并运行游戏 31 | ai = AlienInvasion() 32 | ai.run_game() 33 | -------------------------------------------------------------------------------- /Code/chapter12/page30-31/alien_invasion.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import pygame 4 | 5 | 6 | class AlienInvasion: 7 | """管理游戏资源和行为的类""" 8 | 9 | def __init__(self): 10 | """初始化游戏并创建游戏资源""" 11 | pygame.init() 12 | 13 | self.clock = pygame.time.Clock() 14 | self.screen = pygame.display.set_mode((400, 500)) 15 | self.bg_color = (230, 230, 230) 16 | 17 | pygame.display.set_caption("Alien Invasion") 18 | 19 | def run_game(self): 20 | """开始游戏的主循环""" 21 | while True: 22 | # 侦听键盘和鼠标事件 23 | for event in pygame.event.get(): 24 | if event.type == pygame.QUIT: 25 | sys.exit() 26 | 27 | # 每次循环时都重绘屏幕 28 | self.screen.fill(self.bg_color) 29 | 30 | # 让最近绘制的屏幕可见 31 | pygame.display.flip() 32 | self.clock.tick(60) 33 | 34 | 35 | if __name__ == '__main__': 36 | # 创建游戏实例并运行游戏 37 | ai = AlienInvasion() 38 | ai.run_game() 39 | -------------------------------------------------------------------------------- /Code/chapter12/page33-35/alien_invasion.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import pygame 4 | from settings import Settings 5 | 6 | 7 | class AlienInvasion: 8 | """管理游戏资源和行为的类""" 9 | 10 | def __init__(self): 11 | """初始化游戏并创建游戏资源""" 12 | pygame.init() 13 | 14 | self.clock = pygame.time.Clock() 15 | self.settings = Settings() 16 | self.screen = pygame.display.set_mode((400, 500)) 17 | self.bg_color = (230, 230, 230) 18 | 19 | pygame.display.set_caption("Alien Invasion") 20 | 21 | def run_game(self): 22 | """开始游戏的主循环""" 23 | while True: 24 | # 侦听键盘和鼠标事件 25 | for event in pygame.event.get(): 26 | if event.type == pygame.QUIT: 27 | sys.exit() 28 | 29 | # 每次循环时都重绘屏幕 30 | self.screen.fill(self.bg_color) 31 | 32 | # 让最近绘制的屏幕可见 33 | pygame.display.flip() 34 | self.clock.tick(60) 35 | 36 | 37 | if __name__ == '__main__': 38 | # 创建游戏实例并运行游戏 39 | ai = AlienInvasion() 40 | ai.run_game() 41 | -------------------------------------------------------------------------------- /Code/chapter12/page33-35/settings.py: -------------------------------------------------------------------------------- 1 | class Settings: 2 | """存储游戏《外星人入侵》中所有设置的类""" 3 | 4 | def __init__(self): 5 | """初始化游戏的设置""" 6 | # 屏幕设置 7 | self.screen_width = 1200 8 | self.screen_height = 800 9 | self.bg_color = (230, 230, 230) 10 | -------------------------------------------------------------------------------- /Code/chapter12/ship.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/Code/chapter12/ship.bmp -------------------------------------------------------------------------------- /PPT/chapter1.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter1.pptx -------------------------------------------------------------------------------- /PPT/chapter10.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter10.pptx -------------------------------------------------------------------------------- /PPT/chapter11.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter11.pptx -------------------------------------------------------------------------------- /PPT/chapter12.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter12.pptx -------------------------------------------------------------------------------- /PPT/chapter13.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter13.pptx -------------------------------------------------------------------------------- /PPT/chapter14.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter14.pptx -------------------------------------------------------------------------------- /PPT/chapter15.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter15.pptx -------------------------------------------------------------------------------- /PPT/chapter16.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter16.pptx -------------------------------------------------------------------------------- /PPT/chapter17.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter17.pptx -------------------------------------------------------------------------------- /PPT/chapter18.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter18.pptx -------------------------------------------------------------------------------- /PPT/chapter19.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter19.pptx -------------------------------------------------------------------------------- /PPT/chapter2.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter2.pptx -------------------------------------------------------------------------------- /PPT/chapter20.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter20.pptx -------------------------------------------------------------------------------- /PPT/chapter3.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter3.pptx -------------------------------------------------------------------------------- /PPT/chapter4.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter4.pptx -------------------------------------------------------------------------------- /PPT/chapter5.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter5.pptx -------------------------------------------------------------------------------- /PPT/chapter6.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter6.pptx -------------------------------------------------------------------------------- /PPT/chapter7.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter7.pptx -------------------------------------------------------------------------------- /PPT/chapter8.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter8.pptx -------------------------------------------------------------------------------- /PPT/chapter9.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/scruel/pcc_3e_slides/d92122d85808b01dd6a1b1f6f6dc9801e383fb18/PPT/chapter9.pptx -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Python Crash Course Slides 2 | 3 | [本仓库][repo]包含本人为[《Python Crash Course》][pcc_en]的中文版[《Python 编程:从入门到实践(第三版)》][pcc]所制作的配套图解讲义资源,与原书一起食用时效果更佳。 4 | 5 | 6 | 7 | 8 | 在线预览(推荐下载 PPT,预览加载较慢,且无动画效果): 9 | 10 | https://scruel.github.io/pcc_3e_slides 11 | 12 | 13 | 14 | ## 关于内容 15 | 16 | 本仓库可以算是本人为本书写的笔记,包含了本人阅读后的理解,但使用讲义形式发布。 17 | 18 | 本讲义不仅可用于教学用途,对于自学者来说,对照本讲义一起学习,或许有助于更好地理解原书内容: 19 | 20 | - 讲义基于原书内容和讲解顺序制作,通过合理安排动画效果,便于与原书一起使用 21 | - 绘制了数十张基于 [Excalidraw][excalidraw] ~~和画图~~的手绘图,作为基础知识点的配套图解 22 | - 增加了“扩展一下”,用于提示值得补充学习或了解的基础向内容,以及提供进阶预览 23 | - 增改了部分书中的内容和代码,使得代码更适于讲义的有限版面,以及教学用途 24 | - 微调了一些章节中的小节顺序,便于通过讲义翻页特性来进行对比 25 | 26 | 希望能够对阅读本书的读者们有所帮助,祝大家 **Happy Pythoning!** 27 | 28 | 29 | 30 | ## 杂谈 31 | 32 | 读完后的感受是,这本书确实非常适合入门,零经验也完全可读,涵盖的基础内容几乎面面俱到,且学以致用的小目标很容易达成:学到的知识能马上被运用于本书的项目部分。作者在循序渐进讲解知识的同时,还会不断强调代码整洁高效的重要性,以引导读者养成良好的编码习惯,很多书都不会费如此笔墨来强调好习惯的重要性,所以是非常难能可贵的。 33 | 34 | 虽然已来回校对了好多次,但由于个人时间精力有限,错误和不佳在所难免,所用版式也较为简单,如果发现任何勘误,或有任何建设性的建议,欢迎在 issue 处给出反馈。 35 | 36 | ### 笔记 or 讲义? 37 | 38 | 对于几乎没有经验甚至是零基础的同学来说,记笔记的时候难免不容易抓住重点,甚至可能会给出一些错误的解释;而对于有经验的同学来说,记笔记的时候难免会省去一些(可能影响理解的关键)内容,毕竟笔记面向的主要是记笔记的个人。而不管经验如何,都免不了会有大段的内容摘抄,除非笔记的写作受众是广泛的读者群体,否则实际上的阅读效果可能还没有原书好。 39 | 40 | 对于讲义来说,大家第一时间能想到的,可能会是读书时不少照本宣科的课程讲义。与书籍不同的是,讲义的单页版面有限,但仍需要放下足够的知识点,尤其是文字偏多的页,很容易就变得“照本宣科”。这个版面的局限性,反而让个人做了一些思考,由于这套讲义是配套图书的,因此需要和原书较为一致,在尽量覆盖原书内容的基础上,将文字搬上讲义难免会显得枯燥,所以在个人思前想后之下,决定让这份讲义带上图解二字,当然这也意味着这份讲义的制作,需要花费更多的精力和时间。 41 | 42 | ### 何以图解? 43 | 44 | 有关于图解,市面上也确实有不少所谓的图解 XXX 类的图书或者笔记等内容了,但个人认为其中的大部分的质量,都实在有些不敢恭维: 45 | 46 | - 放的都是一些无助于理解的插图,有一种强行凑版面的感觉,还不如单纯的文字图书。 47 | - 即便插图有助理解,但它们要么缺乏生动形象的比喻,要么是比喻的不够贴切,反而容易造成误导。 48 | 49 | 基于以上,在这份讲义制作的时候,个人主要在关键知识点处加入图解,并且配合讲义功能让图“动起来”,应该能够有助于更好地理解和学习,虽然由于个人绘画能力有限,其实还有一些更好的比喻没能采用,不过已经发布的配图图解,都尽量贴切了知识点本身。 50 | 51 | 52 | 53 | ## 致谢 54 | 55 | 感谢图灵社区编辑老师们的邀约,让本人有此机会为读者们制作本书的随书配套讲义。尤其要感谢王军花老师的督促,让我得以及时完成基础部分的内容。 56 | 57 | 58 | 59 | ## 许可 60 | 61 | [![Creative Commons License](https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png)][license] 62 | 63 | 本作品中的内容采用[知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议][license]进行许可。 64 | 65 | All content of this work is licensed under a [Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License][license_en]. 66 | 67 | 68 | 69 | [repo]: https://github.com/scruel/pcc_3e_slides 70 | [pcc_en]: https://ehmatthes.github.io/pcc_3e 71 | [pcc]: https://www.ituring.com.cn/book/3038 72 | [excalidraw]: https://excalidraw.com 73 | [license]: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh 74 | [license_en]: https://creativecommons.org/licenses/by-nc-sa/4.0/deed.en 75 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | index 595 | 596 |
597 |

Python Crash Course Slides

本仓库包含本人为《Python Crash Course》的中文版《Python 编程:从入门到实践(第三版)》所制作的配套图解讲义资源,与原书一起食用时效果更佳。

 

目录

第一部分 基础知识

第 1 章 起步

第 2 章 变量和简单的数据类型

第 3 章 列表简介

第 4 章 操作列表

第 5 章 if 语句

第 6 章 字典

第 7 章 用户输入和while 循环

第 8 章 函数

第 9 章 类

第 10 章 文件和异常

第 11 章 测试代码

第二部分 项目

(WIP...)

 

关于内容

本仓库可以算是本人为本书写的笔记,包含了本人阅读后的理解,但使用讲义形式发布。

本讲义不仅可用于教学用途,对于自学者来说,对照本讲义一起学习,或许有助于更好地理解原书内容:

 

希望能够对阅读本书的读者们有所帮助,祝大家 Happy Pythoning!

 

杂谈与致谢

读完后的感受是,这本书确实非常适合入门,零经验也完全可读,涵盖的基础内容几乎面面俱到,且学以致用的小目标很容易达成:学到的知识能马上被运用于本书的项目部分。作者在循序渐进讲解知识的同时,还会不断强调代码整洁高效的重要性,以引导读者养成良好的编码习惯,很多书都不会费如此笔墨来强调好习惯的重要性,所以是非常难能可贵的。

虽然已来回校对了好多次,但由于个人时间精力有限,错误和不佳在所难免,所用版式也较为简单,如果发现任何勘误,或有任何建设性的建议,欢迎在 issue 处给出反馈。

 

感谢图灵社区编辑老师们的认可和邀约,让本人有此机会为读者们制作本书的随书配套讲义。尤其要感谢王军花老师的督促,让我得以及时完成基础部分的内容。

 

许可

Creative Commons License

本作品(包括文本和绘图)采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可。

This work (includes text and drawings) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

 

598 | 599 | 600 | --------------------------------------------------------------------------------