Files
book/basic/tips/pythontutor/index.md
2024-12-19 12:02:28 +08:00

82 lines
1.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 使用 [pythontutor.com](https://pythontutor.com/) 可视化的执行流程
![0](image.png)
由于网站都是英文的,所以接下来我会一步步的截图,请按照顺序执行
## 1. 选择编程语言
![1](image-1.png)
## 2. 在输入框中粘贴代码
![2](image-2.png)
```py
n=1
i=0
while i<5:
i=i+1
n=n*2
print(n)
```
## 3. 点击【可视化执行】按钮
![5](image-5.png)
## 4. 进入调试页面
![4](image-4.png)
① 绿色箭头表示【当前正在】执行的语句
② 红色箭头表示【接下来要】执行的语句
③ 输出结果
④ 显示变量的值
## 5. 基础调试
![3](image-3.png)
5.1 不断点击 ①【Next 下一步】按钮
5.2 代码左侧 ② 出现绿色和红色箭头,指向【当前】和【接下来】的执行语句。
5.3 右侧 ③ 实时展示变量的值
**注意观察箭头的走向和变量值的变化**
![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】按钮可以修改代码
![3](PixPin_2024-12-19_11-26-35.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)