This commit is contained in:
2024-12-19 12:02:28 +08:00
parent 38b9807b5c
commit 3ae7becc40
19 changed files with 148 additions and 39 deletions

View File

@@ -45,6 +45,10 @@ export default defineConfig({
link: "/basic/tips/error-message/index.md", link: "/basic/tips/error-message/index.md",
}, },
{ text: "使用 AI", link: "/basic/tips/chatgpt/index.md" }, { text: "使用 AI", link: "/basic/tips/chatgpt/index.md" },
{
text: "可视化执行流程",
link: "/basic/tips/pythontutor/index.md",
},
], ],
}, },
{ {

View File

@@ -3,24 +3,44 @@
> 抄抄抄 > 抄抄抄
1. 输出保留两位小数 1. 输出保留两位小数
```py ```py
a = 10.2980 a = 10.2980
print("%.2f" % a) print("%.2f" % a)
``` ```
2. 输入一个整数 2. 输入一个整数
比如输入128
```py ```py
a=int(input()) a=int(input())
``` ```
得到变量a就是整数128
3. 输入两个整数,用空格隔开 3. 输入两个整数,用空格隔开
比如输入 10 20
```py ```py
n=input().split() n=input().split()
a=int(n[0]) a=int(n[0])
b=int(n[1]) b=int(n[1])
``` ```
4. 输入文字用空格隔开这里用三个文字做例子比如iPhone Huawei Xiaomi 得到变量a就是整数10变量b就是整数20
4. 输入文字,用空格隔开
比如输入 iPhone Huawei Xiaomi
```py ```py
a,b,c=input().split() n=input().split()
a=n[0]
b=n[1]
c=n[2]
``` ```
得到变量a就是iPhone变量b就是Huawei变量c就是Xiaomi

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

View File

@@ -0,0 +1,81 @@
# 使用 [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)

72
package-lock.json generated
View File

@@ -11,12 +11,12 @@
"dependencies": { "dependencies": {
"@codemirror/lang-cpp": "^6.0.2", "@codemirror/lang-cpp": "^6.0.2",
"@codemirror/lang-python": "^6.1.6", "@codemirror/lang-python": "^6.1.6",
"axios": "^1.7.7", "axios": "^1.7.9",
"codemirror": "^6.0.1", "codemirror": "^6.0.1",
"vue-codemirror6": "~1.3.4" "vue-codemirror6": "~1.3.8"
}, },
"devDependencies": { "devDependencies": {
"prettier": "^3.3.3", "prettier": "^3.4.2",
"vitepress": "1.5.0" "vitepress": "1.5.0"
} }
}, },
@@ -472,13 +472,13 @@
} }
}, },
"node_modules/@codemirror/lint": { "node_modules/@codemirror/lint": {
"version": "6.8.2", "version": "6.8.4",
"resolved": "https://registry.npmmirror.com/@codemirror/lint/-/lint-6.8.2.tgz", "resolved": "https://registry.npmmirror.com/@codemirror/lint/-/lint-6.8.4.tgz",
"integrity": "sha512-PDFG5DjHxSEjOXk9TQYYVjZDqlZTFaDBfhQixHnQOEVDDNHUbEh/hstAjcQJaA6FQdZTD1hquXTK0rVBLADR1g==", "integrity": "sha512-u4q7PnZlJUojeRe8FJa/njJcMctISGgPQ4PnWsd9268R4ZTtU+tfFYmwkBvgcrK2+QQ8tYFVALVb5fVJykKc5A==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@codemirror/state": "^6.0.0", "@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0", "@codemirror/view": "^6.35.0",
"crelt": "^1.0.5" "crelt": "^1.0.5"
} }
}, },
@@ -493,18 +493,21 @@
} }
}, },
"node_modules/@codemirror/state": { "node_modules/@codemirror/state": {
"version": "6.4.1", "version": "6.5.0",
"resolved": "https://registry.npmmirror.com/@codemirror/state/-/state-6.4.1.tgz", "resolved": "https://registry.npmmirror.com/@codemirror/state/-/state-6.5.0.tgz",
"integrity": "sha512-QkEyUiLhsJoZkbumGZlswmAhA7CBU02Wrz7zvH4SrcifbsqwlXShVXg65f3v/ts57W3dqyamEriMhij1Z3Zz4A==", "integrity": "sha512-MwBHVK60IiIHDcoMet78lxt6iw5gJOGSbNbOIVBHWVXIH4/Nq1+GQgLLGgI1KlnN86WDXsPudVaqYHKBIx7Eyw==",
"license": "MIT"
},
"node_modules/@codemirror/view": {
"version": "6.34.2",
"resolved": "https://registry.npmmirror.com/@codemirror/view/-/view-6.34.2.tgz",
"integrity": "sha512-d6n0WFvL970A9Z+l9N2dO+Hk9ev4hDYQzIx+B9tCyBP0W5wPEszi1rhuyFesNSkLZzXbQE5FPH7F/z/TMJfoPA==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@codemirror/state": "^6.4.0", "@marijn/find-cluster-break": "^1.0.0"
}
},
"node_modules/@codemirror/view": {
"version": "6.36.0",
"resolved": "https://registry.npmmirror.com/@codemirror/view/-/view-6.36.0.tgz",
"integrity": "sha512-aMePDnkNNKE8dSOo1w689xYa3dijREbRajiRcgjSGc2TWN7MTdE+9pm5fxwdz0C4D9Di1VZomrn2M+xDe7tTVg==",
"license": "MIT",
"dependencies": {
"@codemirror/state": "^6.5.0",
"style-mod": "^4.1.0", "style-mod": "^4.1.0",
"w3c-keyname": "^2.2.4" "w3c-keyname": "^2.2.4"
} }
@@ -1013,6 +1016,12 @@
"@lezer/lr": "^1.0.0" "@lezer/lr": "^1.0.0"
} }
}, },
"node_modules/@marijn/find-cluster-break": {
"version": "1.0.2",
"resolved": "https://registry.npmmirror.com/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==",
"license": "MIT"
},
"node_modules/@rollup/rollup-android-arm-eabi": { "node_modules/@rollup/rollup-android-arm-eabi": {
"version": "4.24.0", "version": "4.24.0",
"resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz", "resolved": "https://registry.npmmirror.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz",
@@ -1705,9 +1714,9 @@
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q=="
}, },
"node_modules/axios": { "node_modules/axios": {
"version": "1.7.7", "version": "1.7.9",
"resolved": "https://registry.npmmirror.com/axios/-/axios-1.7.7.tgz", "resolved": "https://registry.npmmirror.com/axios/-/axios-1.7.9.tgz",
"integrity": "sha512-S4kL7XrjgBmvdGut0sN3yJxqYzrDOnivkBiN0OFs6hLiUam3UPvswUo0kqGyhqUZGEOytHyumEdXsAkgCOUf3Q==", "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"follow-redirects": "^1.15.6", "follow-redirects": "^1.15.6",
@@ -2277,9 +2286,9 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "3.3.3", "version": "3.4.2",
"resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.3.3.tgz", "resolved": "https://registry.npmmirror.com/prettier/-/prettier-3.4.2.tgz",
"integrity": "sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==", "integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"bin": { "bin": {
@@ -2699,32 +2708,27 @@
} }
}, },
"node_modules/vue-codemirror6": { "node_modules/vue-codemirror6": {
"version": "1.3.7", "version": "1.3.8",
"resolved": "https://registry.npmmirror.com/vue-codemirror6/-/vue-codemirror6-1.3.7.tgz", "resolved": "https://registry.npmmirror.com/vue-codemirror6/-/vue-codemirror6-1.3.8.tgz",
"integrity": "sha512-DG2LA5Ps2K8Ot1jlDeaRy28AhI9TKtcbRasT3WMooLxaWfHQcSKtbeANFqRSdECQjXiDVVYNTUte4Y7mR4XtEg==", "integrity": "sha512-pCOzKzBBSFKi/SjUg+XGranV1vt+8S22z56BES/OeZtmyuj2M0CE0aczYS8qbTWNnKcuJcI5FRDHzVXy2v2Htg==",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@codemirror/commands": "^6.7.1", "@codemirror/commands": "^6.7.1",
"@codemirror/language": "^6.10.3", "@codemirror/language": "^6.10.3",
"@codemirror/lint": "^6.8.2", "@codemirror/lint": "^6.8.3",
"@codemirror/state": "^6.4.1", "@codemirror/state": "^6.4.1",
"@codemirror/view": "^6.34.2", "@codemirror/view": "^6.35.0",
"codemirror": "^6.0.1", "codemirror": "^6.0.1",
"style-mod": "^4.1.2", "style-mod": "^4.1.2",
"vue-codemirror6": "file:",
"vue-demi": "latest" "vue-demi": "latest"
}, },
"engines": { "engines": {
"pnpm": ">=9.12.3" "pnpm": ">=9.14.2"
}, },
"peerDependencies": { "peerDependencies": {
"vue": "^2.7.14 || ^3.4" "vue": "^2.7.14 || ^3.4"
} }
}, },
"node_modules/vue-codemirror6/node_modules/vue-codemirror6": {
"resolved": "node_modules/vue-codemirror6",
"link": true
},
"node_modules/vue-demi": { "node_modules/vue-demi": {
"version": "0.14.10", "version": "0.14.10",
"resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.10.tgz", "resolved": "https://registry.npmmirror.com/vue-demi/-/vue-demi-0.14.10.tgz",

View File

@@ -12,14 +12,14 @@
"author": "", "author": "",
"license": "ISC", "license": "ISC",
"devDependencies": { "devDependencies": {
"prettier": "^3.3.3", "prettier": "^3.4.2",
"vitepress": "1.5.0" "vitepress": "1.5.0"
}, },
"dependencies": { "dependencies": {
"@codemirror/lang-cpp": "^6.0.2", "@codemirror/lang-cpp": "^6.0.2",
"@codemirror/lang-python": "^6.1.6", "@codemirror/lang-python": "^6.1.6",
"axios": "^1.7.7", "axios": "^1.7.9",
"codemirror": "^6.0.1", "codemirror": "^6.0.1",
"vue-codemirror6": "~1.3.4" "vue-codemirror6": "~1.3.8"
} }
} }