Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[译] [400] 第四章 理解 Python 代码(上) #25

Open
cssmagic opened this issue Feb 29, 2024 · 0 comments
Open

[译] [400] 第四章 理解 Python 代码(上) #25

cssmagic opened this issue Feb 29, 2024 · 0 comments

Comments

@cssmagic
Copy link
Owner

4 Reading Python Code: Part 1

第四章 理解 Python 代码(上)

This chapter covers

本章内容概要

  • Why knowing how to read code is important
  • How to ask Copilot to explain code
  • Using functions to break a problem into smaller sub-problems
  • Using variables to hang on to values
  • Using if statements to make decisions
  • Using strings to store and manipulate text
  • Using lists to collect and manipulate many values
  • 为什么懂得如何阅读代码很重要
  • 如何让 Copilot 解释代码
  • 利用函数把问题拆分成若干更小的子问题
  • 利用变量保存数据
  • 利用 if 语句进行决策
  • 利用字符串来存储及处理文本
  • 利用列表来收集和处理多个值

In Chapter 3, we used Copilot to write several functions for us. What are they good for? Maybe our money_made function could be part of a stock trading system. Maybe our is_strong_password function could be used as part of a social network website. Maybe our best_word function could be used as part of some Scrabble AI. Overall, we’ve written some useful functions that could be part of larger programs. And we did this without writing much code ourselves or, indeed, understanding what the code even does.

在第三章,我们借助 Copilot 编写了几个有用的函数。这些函数能用在哪里呢?例如,我们的 money_made 函数可能成为股票交易系统的一部分;is_strong_password 函数可以用于社交网站的密码强度检测;best_word 函数则可能应用于 Scrabble 游戏的 AI 中。归根结底,我们编写了若干可以成为大型程序组成部分的实用函数,而这一切几乎不需要我们自己动手编写代码,或者完全理解这些代码的具体作用。

However, we believe that you need to understand at a high-level what code does and that this will require some time to learn, hence we’ve split this across two chapters. In this chapter, we’ll explain why reading code is important and introduce you to a Copilot labs feature that can help you understand the code. After that, we'll dive into the top ten programming features you’ll need to be able to recognize in order to read most basic code produced by Copilot. We’ll do the first five in this chapter and the remaining five in the next chapter. Don't worry: you've actually been informally introduced to all ten already—we're just going to deepen your understanding of each one.

然而,我们相信你需要从高层次理解代码的作用,这将需要一些时间来学习,因此我们将这部分内容分为两章。在本章中,我们将解释为什么阅读代码是重要的,并介绍一个 Copilot 实验室的特性,该特性能帮助你理解代码。之后,我们会深入讨论十个编程特性,这些特性对于阅读 Copilot 产出的大多数基础代码来说是必需认识的。我们会在本章介绍前五个特性,在下一章介绍剩余的五个。不用担心:你其实已经非正式地了解了这十个特性——我们只是要深化你对它们每一个的理解。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant