Skip to content

Commit f8daec6

Browse files
committed
feat: update chapter(s) by CAT
1 parent 3988283 commit f8daec6

File tree

4 files changed

+119
-26
lines changed

4 files changed

+119
-26
lines changed

content/chapter-5/500.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
idxx: 2
2+
id: 11
33
title: "[译] [500] 第五章 阅读 Python 代码(下)"
44
---
55

@@ -16,10 +16,23 @@ title: "[译] [500] 第五章 阅读 Python 代码(下)"
1616
* Adding modules to extend Python into new domains
1717
* Asking Copilot to explain code
1818

19-
In Chapter 4, we explored five Python features that you’re going to see all the time as you continue in your programming journey: functions, variables, conditionals (if statements), strings, and lists. You need to know those features to read code, and we explained why being able to read code is important whether or not we’re using Copilot.
19+
<!-- -->
20+
21+
* 使用循环实现代码的指定次数重复
22+
* 用缩进标识哪些代码是一组
23+
* 建立字典来保存一对一关联的值
24+
* 设置文件读取和处理数据
25+
* 添加模块,使 Python 拓展到新的领域
26+
* 要求 Copilot 对代码进行解释
27+
28+
In Chapter 4, we explored five Python features that you’re going to see all the time as you continue in your programming journey: functions, variables, conditionals (`if` statements), strings, and lists. You need to know those features to read code, and we explained why being able to read code is important whether or not we’re using Copilot.
29+
30+
在第四章中,我们探索了在编程之旅中频繁出现的五个 Python 特性:函数、变量、条件(`if` 语句)、字符串和列表。理解这些功能对阅读代码非常重要,我们还解释了无论是否使用 Copilot,阅读代码的能力都相当重要。
2031

2132
We’re going to continue in this chapter with five more Python features, which will round out our top 10. As in Chapter 4, we’ll do this through a combination of our own explanations, explanations from Copilot, and experimenting at the Python prompt.
2233

34+
本章,我们将继续深入另外五个 Python 功能,使我们的重点功能总数达到十个。与第 4 章的做法一样,我们将通过自己的讲解、Copilot 的解释和在 Python 提示符下进行实验的方式来实现这一目标。
35+
2336
***
2437

2538
* 5.1 Top 10 programming features you need to know: Part 2
@@ -28,3 +41,12 @@ We’re going to continue in this chapter with five more Python features, which
2841
* 5.1.3 #8. Dictionaries
2942
* 5.1.4 #9. Files
3043
* 5.1.5 #10. Modules
44+
45+
<!-- -->
46+
47+
* 5.1 你必须掌握的十大编程特性:第二部分
48+
* 5.1.1 #6. 循环
49+
* 5.1.2 #7. 缩进
50+
* 5.1.3 #8. 字典
51+
* 5.1.4 #9. 文件
52+
* 5.1.5 #10. 模块

content/chapter-6/600.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
idxx: 2
2+
id: 12
33
title: "[译] [600] 第六章 程序测试与提示词工程"
44
---
55

@@ -14,8 +14,17 @@ title: "[译] [600] 第六章 程序测试与提示词工程"
1414
* Addressing errors by Copilot by modifying prompts
1515
* Viewing examples of testing code produced by Copilot
1616

17+
<!-- -->
18+
19+
* 理解测试 Copilot 代码重要性
20+
* 使用黑盒测试与白盒测试
21+
* 通过修改提示词解决 Copilot 的错误
22+
* 查看测试 Copilot 生成代码的示例
23+
1724
In Chapter 3, we first started to see the importance of testing the code produced by Copilot. Testing is an essential skill for anyone writing software because it gives you confidence that the code is functioning properly. In this chapter, we’ll learn how to test our code thoroughly and how to help Copilot fix code that doesn’t work by modifying our prompts.
1825

26+
在第三章,我们初次体会到测试 Copilot 生成代码的重要性。对于编写软件的人而言,测试是一项必不可少的技能,它能够让开发者对代码的正确运行有足够的信心。在这一章中,我们将学习如何对代码进行彻底的测试,并且了解如何通过调整提示词来帮助 Copilot 修复不正确的代码。
27+
1928
***
2029

2130
* 6.1 Why it is crucial to test code
@@ -37,3 +46,25 @@ In Chapter 3, we first started to see the importance of testing the code produce
3746
* 6.6.2 Creating the function
3847
* 6.6.3 Testing the function
3948
* 6.6.4 Common challenges with doctest
49+
50+
<!-- -->
51+
52+
* 6.1 为什么测试代码至关重要
53+
* 6.2 黑盒测试与白盒测试
54+
* 6.2.1 黑盒测试
55+
* 6.2.2 我们如何选定合适的测试用例?
56+
* 6.2.3 白盒测试
57+
* 6.3 如何测试你的代码
58+
* 6.3.1 使用 Python 提示词进行测试
59+
* 6.3.2 在 Python 文件中测试(我们不会采用这种方式)
60+
* 6.3.3 基于 `doctest` 的测试
61+
* 6.4 重新考量有 Copilot 参与的函数设计流程
62+
* 6.5 完整的测试案例
63+
* 6.5.1 找出能加入一行的最多学生数量
64+
* 6.5.2 优化提示词以寻找更优的解决方案
65+
* 6.5.3 测试新方案
66+
* 6.6 另一个完整的测试案例——文件测试
67+
* 6.6.1 我们应运行哪些测试?
68+
* 6.6.2 函数创建
69+
* 6.6.3 函数测试
70+
* 6.6.4 `doctest` 面临的常见问题

content/chapter-7/700.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
idxx: 2
2+
id: 13
33
title: "[译] [700] 第七章 分解问题"
44
---
55

@@ -13,37 +13,48 @@ title: "[译] [700] 第七章 分解问题"
1313
* Using top-down design to carry out problem decomposition and write programs
1414
* Writing an authorship identification program using top-down design
1515

16+
<!-- -->
17+
18+
* 理解问题的分解及其重要性
19+
* 运用自顶向下的设计方法来分解问题并编写程序
20+
* 使用自顶向下的设计编写一个作者识别程序
21+
1622
In Chapter 3, we talked about why we shouldn’t ask Copilot to solve big problems. Imagine what could happen if we asked Copilot, “Write a program to determine the author of a book.”
1723

18-
In the best case, we’d get a canned program with all of the decisions made for us. That program may not match what we wanted. Part of the power of being a programmer is customizing what we’re creating. To do this, we need to feed small subproblems to Copilot and assemble those solutions into a program of our own. Even if we didn’t want to customize anything, what would we do if the program from Copilot had flaws? It would be difficult for us to fix a large program that we don’t understand.
24+
在第三章,我们探讨了为什么不应该要求 Copilot 去解决大型问题。试想一下,如果我们对 Copilot 说 “编写一个判定书籍作者的程序”,会发生什么情况?
25+
26+
In the best case, we’d get a canned program with all of the decisions made for us. That program may not match what we wanted. Part of the power of being a programmer is customizing what we’re creating. To do this, we need to feed small sub-problems to Copilot and assemble those solutions into a program of our own. Even if we didn’t want to customize anything, what would we do if the program from Copilot had flaws? It would be difficult for us to fix a large program that we don’t understand.
27+
28+
在最理想的情况下,我们将获得一个全套的程序,其中所有决策都已经代我们做出。但这个程序可能并不完全满足我们的要求。程序员这个角色的魅力在于能够定制我们所创造的东西。为了实现这一点,我们需要向 Copilot 提出具体的子问题,并将这些解决方案组合成我们自己的程序。或许我们不想定制任何内容,但如果 Copilot 编写的程序存在瑕疵怎么办?修复一个我们不了解的大型程序会非常困难。
1929

2030
In the worst case, Copilot wouldn’t do anything useful. We observe this sometimes when Copilot gives us comments again and again but never provides us with real code.
2131

22-
In this chapter, we will learn how to break large problems into smaller ones. We can then use Copilot to solve each of the small subproblems, thereby solving the large problem that we ultimately care about solving.
32+
在最糟糕的情况下,Copilot 给不出任何有用的东西。我们有时候会发现这种情况,比如 Copilot 只是反复输出注释,而不是提供实质性的代码。
33+
34+
In this chapter, we will learn how to break large problems into smaller ones. We can then use Copilot to solve each of the small sub-problems, thereby solving the large problem that we ultimately care about solving.
35+
36+
在本章中,我们将学习如何将大问题分解成小问题。然后我们可以使用 Copilot 来解决每个小的子问题,从而解决我们最终关心的大问题。
2337

2438
***
2539

2640
* 7.1 Problem decomposition
2741
* 7.2 Small examples of top-down design
2842
* 7.3 Authorship identification
2943
* 7.4 Authorship identification using top-down design
30-
* 7.5 Breaking down the process subproblem
44+
* 7.5 Breaking down the process sub-problem
3145
* 7.5.1 Figuring out the signature for the mystery book
3246
* 7.6 Summary of our top-down design
3347
* 7.7 Implementing our functions
34-
* 7.7.1 clean_word
35-
* 7.7.2 average_word_length
36-
* 7.7.3 different_to_total
37-
* 7.7.4 exactly_once_to_total
38-
* 7.7.5 split_string
39-
* 7.7.6 get_sentences
40-
* 7.7.7 average_sentence_length
41-
* 7.7.8 get_phrases
42-
* 7.7.9 average_sentence_complexity
43-
* 7.7.10 make_signature
44-
* 7.7.11 get_all_signatures
45-
* 7.7.12 get_score
46-
* 7.7.13 lowest_score
47-
* 7.7.14 process_data
48-
* 7.7.15 make_guess
4948
* 7.8 Going further
49+
50+
<!-- -->
51+
52+
7.1 问题分解
53+
7.2 自顶向下设计的示例
54+
7.3 作者身份识别
55+
7.4 应用自顶向下设计识别作者身份
56+
7.5 分解子问题过程
57+
7.5.1 解析神秘书籍的签名
58+
7.6 自顶向下设计的总结
59+
7.7 实现具体函数
60+
7.8 更进一步

content/chapter-8/800.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
2-
idxx: 2
3-
title: "[译] [800] 第八章 调试和更好地理解你的代码"
2+
id: 14
3+
title: "[译] [800] 第八章 调试代码并且更深入地理解代码"
44
---
55

66
# 8 Debugging and Better Understanding Your Code
7-
# 第八章 调试和更好地理解你的代码
7+
# 第八章 调试代码并且更深入地理解代码
88

99
### This chapter covers
1010
### 本章内容概要
@@ -14,12 +14,25 @@ title: "[译] [800] 第八章 调试和更好地理解你的代码"
1414
* Debugging code with Copilot
1515
* Using VS Code debugger to see how code is functioning
1616

17-
There will be a point in every programmer’s career when their code isn’t doing what they want it to do. This has likely happened to you already, and, rest assured, it is a normal part of learning to program. How do we fix the code? Sometimes, changing the prompt or better decomposing the problem like you learned in earlier chapters is sufficient to fix the problem. But what do you do when you just can’t get Copilot to give you different or better code and you can’t seem to figure out why the code you’ve been given doesn’t work properly?
17+
* 查明 bug 的根源
18+
* 通过 Copilot 技巧修正错误
19+
* 借助 Copilot 对代码进行调试
20+
* 使用 VS Code 的调试器观察代码如何运作
21+
22+
23+
24+
There will be a point in every programmer’s career when their code isn’t doing what they want it to do. This has likely happened to you already, and, rest assured, it is a normal part of learning to program. How do we fix the code? Sometimes, changing the prompt or better decomposing the problem like you learned in earlier chapters is sufficient to fix the problem. But what do you do when you just can’t get Copilot to give you different or better code, and you can’t seem to figure out why the code you’ve been given doesn’t work properly?
25+
26+
在每位程序员的职业道路上,都会遇到代码不按他们所愿执行的时刻。这很可能已经发生在你身上,而且,请放心,这是学习编程过程中的一部分。我们如何修正代码?有时,改变提示词或者如前几章所学,更精确地分解问题就足以解决问题。但是,当你无法让 Copilot 提供不同或更好的代码,又或者无法搞清楚为什么你得到的代码不能正常工作时,你应该怎么办?
1827

1928
This chapter serves two purposes. The primary goal is to learn how to find errors (called bugs) in the code and fix them. To find those bugs, you’ll need to fulfill the second goal, which is gaining a deeper understanding of how your code works while you are running it.
2029

30+
本章节的目标有二。首要任务是学习如何发现代码中的错误(俗称 bug)并予以修复。而为了找到这些错误,你还需实现第二个目标,那就是在代码执行时深入理解其运作原理。
31+
2132
The good news is that having an error in your code is such a common occurrence for programmers that programming environments, like Visual Studio Code (VS Code), have tools to help us uncover what is going wrong. We’ll learn how to use that tool, called a debugger, in this chapter as well.
2233

34+
值得庆幸的是,代码出现错误对编程人员来说极为常见,以至于像 Visual Studio Code(VS Code)这种编程环境都配备了工具来帮助我们找出问题所在。本章我们将学习如何使用这种称为调试器的工具。
35+
2336
...
2437

2538
***
@@ -37,3 +50,19 @@ The good news is that having an error in your code is such a common occurrence f
3750
* 8.5 Applying our debugging skills to a new problem
3851
* 8.6 Using the debugger to better understand code
3952
* 8.7 A caution about debugging
53+
54+
<!-- -->
55+
56+
8.1 导致错误(bug)的原因是什么?
57+
8.2 如何定位 bug
58+
8.2.1 使用 print 语句来了解代码的行为
59+
8.2.2 使用 VS Code 的调试工具来了解代码的行为
60+
8.3 找到 bug 后如何修复
61+
8.3.1 通过对话让 Copilot 帮你修复 bug
62+
8.3.2 为整个函数给 Copilot 一个新的提示
63+
8.3.3 为函数的一部分给 Copilot 一个具体的提示
64+
8.3.4 自己修改代码修复 bug
65+
8.4 根据新技能调整我们的工作流
66+
8.5 将调试技巧应用到新问题上
67+
8.6 使用调试器更深入地理解代码
68+
8.7 调试的注意事项

0 commit comments

Comments
 (0)