This commit is contained in:
2024-12-19 22:50:59 +08:00
parent 3ae7becc40
commit 4920667ac9
24 changed files with 89 additions and 42 deletions

View File

@@ -0,0 +1,3 @@
:lang(zh) {
--vp-code-copy-copied-text-content: '已复制'
}

View File

@@ -3,6 +3,7 @@ import DefaultTheme from "vitepress/theme"
import BVideo from "./components/BVideo.vue" import BVideo from "./components/BVideo.vue"
import Author from "./components/Author.vue" import Author from "./components/Author.vue"
import CodeEditor from "./components/CodeEditor.vue" import CodeEditor from "./components/CodeEditor.vue"
import './custom.css'
export default { export default {
extends: DefaultTheme, extends: DefaultTheme,

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

View File

@@ -0,0 +1,60 @@
# 调试并记录
## [前提自学](/basic/tips/pythontutor/)
现在需要记录每次的调试过程,分别需要记录:
1. 初始值
2. 循环的条件
3. 条件的值
4. 计数器每次加的值
5. 循环的次数
每一项所对应的代码,如图:
![0](image.png)
每次填写后,刷新网页再次填写。
打开:[https://lc.xuyue.cc/public-forms/do0zqi0xlpe](https://lc.xuyue.cc/public-forms/do0zqi0xlpe)
## 第一步 两人一组,一人负责调试,一人负责记录
![6](image-6.png)
## 第二步 修改一次代码,调试并记录
你可以选择以下其中一种,修改代码,调试并记录。
1. 修改初始值,举个例子,从初始值 0 改为 2
![3](image-3.png)
2. 修改循环的条件,举个例子,从小于改为小于等于
![7](image-7.png)
3. 修改条件的数值,举个例子,从 5 改为 10
![8](image-8.png)
4. 修改计数器每次加的数,举个例子,从 1 改为 2
![9](image-9.png)
## 第三步 在自测猫中修改代码,记录
打开:[https://code.xuyue.cc/?query=5](https://code.xuyue.cc/?query=5)
每次修改【初始值、循环的条件、条件的值、计数器每次加的值】,运行查看循环次数,并记录。
比如:
![12](image-12.png)
每组至少记录 5 份。

Binary file not shown.

Before

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 219 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 424 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 190 KiB

After

Width:  |  Height:  |  Size: 157 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 188 KiB

View File

@@ -1,81 +1,64 @@
# 使用 [pythontutor.com](https://pythontutor.com/) 可视化执行流程 # 可视化执行流程
![0](image.png) 如图演示,我们可以精确控制代码的执行流程。
由于网站都是英文的,所以接下来我会一步步的截图,请按照顺序执行 ![0](PixPin_2024-12-19_19-54-46.gif)
## 1. 选择编程语言 打开 [pythontutor.com](https://pythontutor.com/),由于网站都是英文的,所以接下来我会一步步的截图,请按照顺序执行。
## 第一步 选择编程语言
![1](image-1.png) ![1](image-1.png)
## 2. 在输入框中粘贴代码 ## 第二步 在输入框中粘贴代码
![2](image-2.png) ![2](image-2.png)
```py ```py
n=1
i=0 i=0
while i<5: while i<5:
i=i+1 i=i+1
n=n*2 print(i)
print(n)
``` ```
## 3. 点击【可视化执行】按钮 ## 第三步 点击【可视化执行】按钮
![5](image-5.png) ![5](image-5.png)
## 4. 进入调试页面 ## 第四步 进入调试页面
![4](image-4.png) ![4](image-4.png)
绿色箭头表示【当前正在】执行的语句 点击下一步
② 红色箭头表示【接下来要】执行的语句 绿色箭头表示【当前正在】执行的语句,红色箭头表示【下一步要】执行的语句
输出结果 显示变量的值
显示变量的值 输出的内容
## 5. 基础调试 ## 第五步 调试代码
![3](image-3.png) ![1](PixPin_2024-12-19_19-45-49.gif)
5.1 不断点击【Next 下一步】按钮 5.1 不断点击【Next】按钮
5.2 代码左侧 ② 出现绿色和红色箭头,指向【当前】和【接下来】的执行语句。 5.2 ① 注意【绿色】和【红色箭头的走动
5.3 右侧 ③ 实时展示变量的值 5.3 ② 变量的值随着代码的执行而发生变化
**注意观察箭头的走向和变量值的变化** 5.4 ③ 输出内容的变化
![1](PixPin_2024-12-19_11-19-48.gif) **注意观察箭头的行走和值的变化**
## 6. 拖动进度条 * ## 第六步 更改代码再次调试
可以拖动进度条反复查看或者点击【First】跳到第一步【Last】直接跳到最后一步
![2](PixPin_2024-12-19_11-22-54.gif)
## 7. 更改代码再次调试
点击【Edit this code】按钮可以修改代码 点击【Edit this code】按钮可以修改代码
![3](PixPin_2024-12-19_11-26-35.gif) ![2](PixPin_2024-12-19_19-58-47.gif)
**可以更改 i 的初始值 i=?,条件符号,条件值,计数器 i=i+? 等**
![6](image-6.png)
比如:
![7](image-7.png)
![8](image-8.png)
![9](image-9.png)
遇到弹框,直接点按钮 遇到弹框,直接点按钮
![10](image-10.png) ![10](image-10.png)
## [完成任务](/basic/tasks/pythontutor/)