You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Adding modules to extend Python into new domains
17
17
* Asking Copilot to explain code
18
18
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.
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.
* Addressing errors by Copilot by modifying prompts
15
15
* Viewing examples of testing code produced by Copilot
16
16
17
+
<!---->
18
+
19
+
* 理解测试 Copilot 代码重要性
20
+
* 使用黑盒测试与白盒测试
21
+
* 通过修改提示词解决 Copilot 的错误
22
+
* 查看测试 Copilot 生成代码的示例
23
+
17
24
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.
* Using top-down design to carry out problem decomposition and write programs
14
14
* Writing an authorship identification program using top-down design
15
15
16
+
<!---->
17
+
18
+
* 理解问题的分解及其重要性
19
+
* 运用自顶向下的设计方法来分解问题并编写程序
20
+
* 使用自顶向下的设计编写一个作者识别程序
21
+
16
22
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.”
17
23
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.
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.
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.
21
31
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.
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.
* Using VS Code debugger to see how code is functioning
16
16
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?
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.
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.
22
33
34
+
值得庆幸的是,代码出现错误对编程人员来说极为常见,以至于像 Visual Studio Code(VS Code)这种编程环境都配备了工具来帮助我们找出问题所在。本章我们将学习如何使用这种称为调试器的工具。
35
+
23
36
...
24
37
25
38
***
@@ -37,3 +50,19 @@ The good news is that having an error in your code is such a common occurrence f
37
50
* 8.5 Applying our debugging skills to a new problem
38
51
* 8.6 Using the debugger to better understand code
0 commit comments