update
@@ -3,24 +3,44 @@
|
||||
> 抄抄抄
|
||||
|
||||
1. 输出保留两位小数
|
||||
|
||||
```py
|
||||
a = 10.2980
|
||||
print("%.2f" % a)
|
||||
```
|
||||
|
||||
|
||||
2. 输入一个整数
|
||||
|
||||
比如输入128
|
||||
|
||||
```py
|
||||
a=int(input())
|
||||
```
|
||||
|
||||
得到变量a就是整数128
|
||||
|
||||
3. 输入两个整数,用空格隔开
|
||||
|
||||
比如输入 10 20
|
||||
|
||||
```py
|
||||
n=input().split()
|
||||
a=int(n[0])
|
||||
b=int(n[1])
|
||||
```
|
||||
|
||||
4. 输入文字,用空格隔开(这里用三个文字做例子,比如:iPhone Huawei Xiaomi)
|
||||
得到变量a就是整数10,变量b就是整数20
|
||||
|
||||
4. 输入文字,用空格隔开
|
||||
|
||||
比如输入 iPhone Huawei Xiaomi
|
||||
|
||||
```py
|
||||
a,b,c=input().split()
|
||||
n=input().split()
|
||||
a=n[0]
|
||||
b=n[1]
|
||||
c=n[2]
|
||||
```
|
||||
|
||||
得到变量a就是iPhone,变量b就是Huawei,变量c就是Xiaomi
|
||||
|
||||
BIN
basic/tips/pythontutor/PixPin_2024-12-19_11-19-48.gif
Normal file
|
After Width: | Height: | Size: 260 KiB |
BIN
basic/tips/pythontutor/PixPin_2024-12-19_11-22-54.gif
Normal file
|
After Width: | Height: | Size: 154 KiB |
BIN
basic/tips/pythontutor/PixPin_2024-12-19_11-26-35.gif
Normal file
|
After Width: | Height: | Size: 496 KiB |
BIN
basic/tips/pythontutor/image-1.png
Normal file
|
After Width: | Height: | Size: 93 KiB |
BIN
basic/tips/pythontutor/image-10.png
Normal file
|
After Width: | Height: | Size: 166 KiB |
BIN
basic/tips/pythontutor/image-2.png
Normal file
|
After Width: | Height: | Size: 112 KiB |
BIN
basic/tips/pythontutor/image-3.png
Normal file
|
After Width: | Height: | Size: 92 KiB |
BIN
basic/tips/pythontutor/image-4.png
Normal file
|
After Width: | Height: | Size: 190 KiB |
BIN
basic/tips/pythontutor/image-5.png
Normal file
|
After Width: | Height: | Size: 52 KiB |
BIN
basic/tips/pythontutor/image-6.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
basic/tips/pythontutor/image-7.png
Normal file
|
After Width: | Height: | Size: 9.4 KiB |
BIN
basic/tips/pythontutor/image-8.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
basic/tips/pythontutor/image-9.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
basic/tips/pythontutor/image.png
Normal file
|
After Width: | Height: | Size: 188 KiB |
81
basic/tips/pythontutor/index.md
Normal file
@@ -0,0 +1,81 @@
|
||||
# 使用 [pythontutor.com](https://pythontutor.com/) 可视化的执行流程
|
||||
|
||||

|
||||
|
||||
由于网站都是英文的,所以接下来我会一步步的截图,请按照顺序执行
|
||||
|
||||
## 1. 选择编程语言
|
||||
|
||||

|
||||
|
||||
## 2. 在输入框中粘贴代码
|
||||
|
||||
|
||||

|
||||
|
||||
```py
|
||||
n=1
|
||||
i=0
|
||||
while i<5:
|
||||
i=i+1
|
||||
n=n*2
|
||||
print(n)
|
||||
```
|
||||
|
||||
## 3. 点击【可视化执行】按钮
|
||||
|
||||

|
||||
|
||||
## 4. 进入调试页面
|
||||
|
||||

|
||||
|
||||
① 绿色箭头表示【当前正在】执行的语句
|
||||
|
||||
② 红色箭头表示【接下来要】执行的语句
|
||||
|
||||
③ 输出结果
|
||||
|
||||
④ 显示变量的值
|
||||
|
||||
## 5. 基础调试
|
||||
|
||||

|
||||
|
||||
5.1 不断点击 ①【Next 下一步】按钮
|
||||
|
||||
5.2 代码左侧 ② 出现绿色和红色箭头,指向【当前】和【接下来】的执行语句。
|
||||
|
||||
5.3 右侧 ③ 实时展示变量的值
|
||||
|
||||
**注意观察箭头的走向和变量值的变化**
|
||||
|
||||

|
||||
|
||||
## 6. 拖动进度条 *
|
||||
|
||||
可以拖动进度条反复查看,或者点击【First】跳到第一步,【Last】直接跳到最后一步
|
||||
|
||||

|
||||
|
||||
## 7. 更改代码再次调试
|
||||
|
||||
点击【Edit this code】按钮可以修改代码
|
||||
|
||||

|
||||
|
||||
**可以更改 i 的初始值 i=?,条件符号,条件值,计数器 i=i+? 等**
|
||||
|
||||

|
||||
|
||||
比如:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
遇到弹框,直接点按钮
|
||||
|
||||

|
||||