Learn Python 3 the Hard Way cover

Learn Python 3 the Hard Way

Rating 3.9
Word count
382K words
Chapters
40
Series
Learn Python the Hard Way
ISBN
9787115478818

Tags

Summary

This is the Chinese edition of the Learn Python the Hard Way series for Python 3, rewritten from the original for Python 3.6 and positioned as a self-study tutorial for absolute beginners. Apart from Exercise 0: Preparation, the book contains 52 exercises. The first 26 cover basic topics such as printing, comments, numbers and math, variables and naming, strings and text, reading and writing files, and functions and return values. The second 26 progress step by step into Boolean expressions, if branches, while and for loops, lists and dictionaries, modules, classes and objects, inheritance and composition, and conclude with project exercises including automated testing, a project skeleton, a website, and a web game. Each exercise follows a consistent format: first the coding task and the expected result, then reinforcement drills and a break it section, and finally a Q&A of common questions. The author advocates not using an integrated development environment, instead completing the exercises in a command-line terminal with a simple text editor and the Python interpreter, so that readers understand how the computer and the tools work while doing the work themselves. The book also stresses no copying and pasting, requiring code to be typed in character by character, so that making mistakes, seeing errors, and debugging build the habit of reading code and troubleshooting. An appendix provides a command-line crash course to help readers unfamiliar with the terminal pick up the basics.

Editor's review

这是一本少见的“边做边学”型编程入门书,它最大的价值不在讲解,而在于用 52 个明确的操作指令把读者摁在键盘前。它的方法论可以概括成三句话:把每个习题做完,把每段代码一字不差敲出来,把程序跑起来。看起来笨拙,却精准地补上了初学者最容易缺失的一环:对代码细节的敏感度、对报错的耐受度,以及独立排查问题的能力。 与多数教程不同,本书刻意绕开集成开发环境,要求读者在终端里用最简单的文本编辑器和 Python 解释器完成全部练习。这种“不便利”是有意为之,能让读者在练习中顺带熟悉路径、文件、命令行等基本功,而不是停留在点按钮的层面。每道习题后的“应该看到的结果”“巩固练习”“破坏程序”“常见问题回答”构成完整闭环,尤其“破坏程序”环节,鼓励读者故意改坏代码再修好,把调试从挫折变成训练。 需要注意,本书的强项是用习题练手,弱项是知识体系的系统讲解,遇到概念性疑问还需配合其他教材补充。中文版依据 Python 3.6 编写,个别示例在更新的版本上可能需要微调。总体而言,它适合作为第一本“动手书”,而不是唯一一本“参考书”。

Who it's for

A good fit for

  • 完全没有编程经验、想靠动手练习入门 Python 的初学者
  • 上过网课却总停留在“看得懂写不出”阶段的编程学习者
  • 希望通过命令行与文本编辑器打牢基本功的自学者
  • 把本书当作教学讲义、给零基础学生布置练习的培训讲师

Not a good fit for

  • 已有多年 Python 经验、想深入研究语言进阶特性的开发者
  • 希望直接学习数据分析、爬虫或机器学习等应用方向的人
  • 偏爱系统性理论讲解、不适应习题驱动式学习的读者

Reading tips

  1. 严格按顺序逐题完成,不要跳读,也不要用复制粘贴替代手敲代码
  2. 每题的“巩固练习”和“破坏程序”务必做完,故意改坏再修好比一次跑通更有收获
  3. 在命令行中操作并留心每一条报错信息,把报错当作线索而非障碍
  4. 发现 Python 3.6 之后版本的行为差异时,先查官方文档,再决定是否调整示例

About the publisher

Posts & Telecom Press China · Founded in 1953

Posts & Telecom Press is known for its strengths in science and technology, computing, and information and communications titles, and has extended its publishing into photography, art, software learning, and inspirational growth, giving it a fairly diverse range. Its catalog includes computing and communications works such as Refactoring and Patterns (Revised Edition) and Huawei Switch Learning Guide (Second Edition), alongside bilingual collector's editions such as The Little Prince (Chinese-English-French illustrated collector's edition), The Great Gatsby, and Three Days to See. Beijing Ten Years: 1980-1990 and Ghost Blade: WLOP Personal Illustration Collection reflect its presence in photography and art. Its authors include Antoine de Saint-Exupéry, Helen Keller, Joshua Kerievsky, Wang Da, Zhang Zhaozeng, and WLOP.

Contents

  1. Exercise 0: Preparation (macOS, Windows, Linux, Searching Online, Advice for Beginners, Optional Text Editors)
  2. Exercise 1: A Good First Program
  3. Exercise 2: Comments and Pound Characters
  4. Exercise 3: Numbers and Math
  5. Exercise 4: Variables and Names
  6. Exercise 5: More Variables and Printing
  7. Exercise 6: Strings and Text
  8. Exercise 7: More Printing
  9. Exercise 8: Printing, Printing
  10. Exercise 9: Printing, Printing, Printing
  11. Exercise 10: What Was That? (Escape Sequences)
  12. Exercise 11: Asking Questions
  13. Exercise 12: Prompting People
  14. Exercise 13: Parameters, Unpacking, Variables
  15. Exercise 14: Prompting and Passing
  16. Exercise 15: Reading Files
  17. Exercise 16: Reading and Writing Files
  18. Exercise 17: More Files
  19. Exercise 18: Names, Variables, Code, Functions
  20. Exercise 19: Functions and Variables
  21. Exercise 20: Functions and Files
  22. Exercise 21: Functions Can Return Something
  23. Exercise 22: What You Have Learned So Far
  24. Exercise 23: Strings, Byte Strings, and Character Encoding
  25. Exercise 24: More Practice
  26. Exercise 25: Even More Practice
  27. Exercise 26: Congratulations, Take a Test!
  28. Exercise 27: Memorizing Logic
  29. Exercise 28: Boolean Expression Practice
  30. Exercise 29: What If
  31. Exercise 30: Else and If
  32. Exercise 31: Making Decisions
  33. Exercise 32: Loops and Lists
  34. Exercise 33: While Loops
  35. Exercise 34: Accessing Elements of Lists
  36. Exercise 35: Branches and Functions
  37. Exercise 36: Designing and Debugging
  38. Exercise 37: Reviewing Various Symbols
  39. Exercise 38: Doing Things to Lists
  40. Exercise 39: Dictionaries, Oh Lovely Dictionaries

FAQ

这本书适合完全没有编程基础的人吗?
适合。全书从打印文字、数学计算和变量开始,默认读者没有编程经验,用逐题操作的方式推进,前提是愿意按部就班地做完 52 个习题,而不是翻阅式的阅读。
为什么书中要求不用 PyCharm 等集成开发环境?
作者希望读者在终端里直接运行代码,同时熟悉路径、文件和命令行操作。绕开 IDE 能减少“点一下就跑起来”的黑箱感,让初学者理解程序从文件到运行的真实过程。
这本书用的是 Python 2 还是 Python 3?
本版即《笨办法学Python 3》,依据 Python 3.6 编写,全部示例面向 Python 3。用更新版本练习时大部分内容仍然适用,个别输出格式或语法细节可能需要对照官方文档调整。
“禁止复制粘贴”真的有必要吗?
有必要。逐字录入会让读者在不知不觉中注意标点、缩进和大小写,敲错后报错再修正的过程,正是作者训练代码阅读能力和调试直觉的核心手段。
读完这本还要再看别的 Python 书吗?
建议补充。本书侧重动手练习与基础操作,语法体系的系统讲解较少,可在完成本书后配合一本系统的入门教材或官方教程,再转向感兴趣的应用方向。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category