自学方法与 Python 工程基础 480 分钟(8 小时专注学习)

第 1 天:诊断、学习方法与环境

使用诊断、预测-实验-复盘、提取练习、概念分解和已验证的终端环境;现有突变示例是共享 tracer bullet,不重复复制。

90 min 独立掌握检查 (Independent Mastery Check);在记录预测与观测输出之后获得的帮助仅用于补救复习,不代表借助 AI 完成本检查——被评估的解释必须独立撰写,接受过辅助补救后须再进行一次新的独立检查方可申报掌握。

学习方法、极简复现与预测-实验-复盘惯例

前置要求

高中阅读理解能力与终端基础认知;无需预先掌握复杂 Python 语法。

学习目标

在已有的变更追踪样例上进行诊断自检并运用“预测-实验-复盘”闭环:在运行任何代码或测试前明确书写预期结果(Prediction),执行后比对差异(Experiment),提炼出极简复现用例与根因假设(Review),再将该概念分解为名称、对象、变更、分配与证据。

操作指引

在编程与模型调试中,盲目尝试提示词或反复猜测只会掩盖真实认知漏洞。本活动要求针对一个变量可变性与引用的经典案例,严格遵循“预测-实验-复盘”闭环进行分析。

自主演练与记录

请观察以下 Python 代码片段,在下方草稿区明确写出你的预测输出(包含变量值与对象同一性假设),不要提前运行:

a = [1, 2, 3]
b = a
b.append(4)
c = a + [5]
print('Case 1:', a)
print('Case 2:', c)
print('Case 3:', a is b, a is c)

预测完成后,分析为什么 b.append(4) 会改变 a,而 a + [5] 不会改变 a。再构思一份最小复现用例(MRE):一段证明 b 与 a 引用同一对象的简短见证代码——它不仅是应对非预期行为的手段,更是同一性主张的证据,因此即使所有预测都正确也必须提交。

第一天客观诊断测验:对象引用与就地修改

请回答以下题目检验掌握情况。提交前请诚实声明你的辅助条件。

声明辅助条件

说明:无 AI 辅助属于诚实声明条件,非平台监控或强制检测手段。

1.

运行代码 a = [1, 2, 3]; b = a; b.append(4) 后,a 的最终值是什么?

2.

接着执行 c = a + [5],表达式 a is c 的求值结果是什么?

3.

下列哪一项准确描述了 Python 中 b = a 赋值语句的底层机制?

作答应证与历史记录

    学习项目提交与证据

    提示:粘贴的执行日志与文字说明属于自述证据,不自动构成独立检查或自动化测试结果。

    0 / 4096 bytes
    声明的辅助条件

    注:无 AI 辅助属于诚实声明条件,而非平台监控。

    当前提交的证据详情

    暂无提交记录。
    独立掌握标准:

    掌握标准:学习者能够在不依赖外部 AI 辅助的情况下,准确预测原地修改与对象创建的差异,并独立写出包含预测、实测验证与根因解释的 3 步诊断记录,以及一份最小的同一性/变更见证用例(MRE)——无论预测结果如何都必须提交。

    权威源资源与权利证明

    链接引用(合法外部引用,无未授权导入) PSF License Version 2

    Python 数据模型与可变性官方参考

    作者 / 机构: Python 软件基金会 (Python Software Foundation) | 原始出处链接 ↗

    对应章节 / 时间戳: 第 3.1 节与第 3.2 节(对象、值与类型)

    验证版本与日期: Python 3.12 官方文档(验证日期:2026-10-30)

    入选理由:

    关于 Python 变量引用、对象同一性(identity)与值语义(value)的权威规范来源,杜绝网络二手教程中的概念误导。

    来源前置条件:

    基础终端操作意识与高中阅读理解能力

    安全回退方案(离线弹性):

    官方文档可通过本地 Python 自带的 pydoc 离线查阅,课程内部提供完全自包含的代码解释与本地验证测试,外部网络中断不影响完整学习体验。

    对比候选资源与选型分析 (4)
    MIT OCW 6.0001 (Prof. Eric Grimson) ↗ 对比评估(Day 01 未采纳) [CC BY-NC-SA 4.0]

    教学清晰度极高,但偏向传统学期制讲座节奏,不如官方规范直接服务于最小复现反思循环(MRE)。保留为补充参考。

    Stanford CS336: Language Modeling from Scratch (Spring 2024) ↗ 对比评估(延后阶段采纳) [No license declared (the repository has no LICENSE file, so all rights are reserved by default)]

    工程深度极高,但前置依赖完整 PyTorch 与 CUDA 环境,延后至 Day 30-60 模型训练阶段引入。

    3Blue1Brown: 线性代数的本质 ↗ 对比评估(延后阶段采纳) [3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions]

    几何直觉无与伦比,针对 Day 10-18 数学基础采纳,不适用于 Day 01 基础引用教学。

    Andrej Karpathy: 零基础构建神经网络 (micrograd) ↗ 对比评估(延后阶段采纳) [MIT (Repository) / Standard YouTube License (Video)]

    自底向上自动求导教学典范。代码为 MIT 许可,但 YouTube 视频字幕权利不明,严禁全文字幕导入,仅以合法外链与原创解释形式在 Day 19-25 结合。

    可选讲解视听资源(如无法访问不影响学习)

    提示:外部可选视听资源当前不可用。本课程所有文字讲解、自包含练习、提示与掌握标准均完全离线可用,无需等待外部媒体。

    120 min 独立掌握检查 (Independent Mastery Check)

    Python 环境建立、终端操作与虚拟环境隔离

    前置要求

    现代操作系统终端访问权限。

    学习目标

    在空沙箱目录中创建干净的 Python 3.12+ 虚拟环境,并用 `sys.prefix`、`sys.executable` 与 `python -m pip` 验证解释器与包隔离。

    操作指引

    在 POSIX shell(Linux/macOS 的 bash 或 zsh)中完成评估。请在未激活任何虚拟环境的新终端中开始——开始前的探针必须输出 True,并记录它报告的解释器路径与 prefix 路径。文末给出 Windows 对应命令,但在本材料中未实际执行。

    python3 --version
    python3 -c "import sys; print(sys.executable); print(sys.prefix); print(sys.base_prefix); print(sys.prefix == sys.base_prefix)"
    mkdir venv-sandbox && cd venv-sandbox
    printf 'marker\n' > marker.txt
    python3 -m venv .venv
    . .venv/bin/activate          # bash/zsh; cmd.exe and PowerShell differ (below)
    echo "$VIRTUAL_ENV"
    python -c "import sys; print(sys.executable); print(sys.prefix); print(sys.base_prefix); print(sys.prefix == sys.base_prefix)"
    python -c "print(open('marker.txt').read().strip())"
    python -m pip --version
    deactivate
    python3 -c "import sys; print(sys.executable); print(sys.prefix); print(sys.base_prefix); print(sys.prefix == sys.base_prefix)"

    期望不变量:
    - python3 --version 报告 Python 3.12 或更高版本后再继续。
    - 新 shell 中的开始前探针输出 sys.prefix == sys.base_prefix 为 True;把这些路径记录为你的“之前状态”。
    - 激活后 $VIRTUAL_ENV 指向 .venv 目录;sys.executable 解析到 .venv 内;sys.prefix 等于 .venv 路径而 sys.base_prefix 仍指向基础安装——这一差异即隔离的验证依据。sys.executable 报告的是调用路径(可能是符号链接),因此以 prefix 的值为准,不要去解析物理可执行文件。
    - venv 解释器自己读取 marker.txt 并输出 marker:venv 的 Python 进程仍能读取 .venv 之外、工作目录之内的文件——被隔离的是解释器/包,而非文件系统沙箱。
    - python -m pip --version 报告来自 .venv site-packages 的 pip;python -m pip 使 pip 与当前解释器配对。
    - deactivate 后,结尾探针输出与记录的之前状态一致(sys.prefix == sys.base_prefix 再次为真)。

    Windows 对应命令(参考命令,本材料未实际执行验证):用 py -m venv .venv 创建;用 .venv\Scripts\Activate.ps1(PowerShell)或 .venv\Scripts\activate.bat(cmd.exe)激活;诊断用 PowerShell 的 $env:VIRTUAL_ENV、cmd.exe 的 %VIRTUAL_ENV%,并用 where.exe python 代替 command -v/echo $PATH。deactivate、python -c 以及 sys.prefix/sys.base_prefix 检查相同。

    若没有可用且受支持的 Python,请按练习中的记录回退方案执行,不要为未完成的虚拟环境部分申报掌握。

    范围说明:虚拟环境通过 sys.prefix/sys.path 隔离 Python 解释器及其已安装的包。正如 venv 的 Python 读取 marker 所示,它不是文件系统或安全沙箱:在其中运行的程序仍可读取你的文件;它也不锁定 Python 版本。

    自主演练与记录

    在未激活任何虚拟环境的新终端中执行完整序列:记录开始前探针;在新建空目录中创建 .venv 并激活;记录 echo $VIRTUAL_ENV、venv 内探针、venv 解释器读取 marker.txt 和 python -m pip --version;然后 deactivate 并确认结尾探针与记录的之前状态一致。若 python3 --version 失败或报告低于 3.12 的版本,不要申报既定环境:若只有较旧解释器,记录观测版本并明确按其版本范围执行同样的检查;若完全没有解释器,记录 command -v python3(Windows 用 where.exe python)、python3 --version、echo $PATH(Windows 用 %PATH% / $env:PATH)与观测到的错误,并把安装 Python 排为补救任务。未执行的虚拟环境任务不构成掌握证据。

    独立掌握标准:

    在未激活任何环境的新 shell 中,于新建目录独立完成 创建→激活→验证→退出 全流程,产出的记录中 venv 内探针显示 `sys.prefix != sys.base_prefix` 且 `python -m pip` 解析到 `.venv` 内、`marker.txt` 读取证明其非文件系统沙箱、结尾探针与记录的之前状态一致,并能用一句话正确区分解释器隔离与文件系统/安全沙箱。若无受支持的 Python,则不为本部分申报掌握,以已记录的回退证据与补救任务代替。

    权威源资源与权利证明

    linking PSF License Version 2

    The Python Tutorial: Virtual Environments and Packages

    作者 / 机构: Python Software Foundation | 原始出处链接 ↗

    对应章节 / 时间戳: Section 12 (creating venvs, pip installs, requirements files)

    验证版本与日期: Python 3.12 (Verified: 2026-10-30)

    入选理由:

    Primary reference for python -m venv and interpreter isolation, which the Day 01 drill checks through activation, the sys.prefix/sys.base_prefix probes, and python -m pip --version; its requirements-file and wrong-environment material is practiced later, on Study Day 11.

    来源前置条件:

    Basic Python syntax from Study Days 01-09

    安全回退方案(离线弹性):

    The Day 01 drill needs no network: venv creation and activation, the sys.executable/sys.prefix/sys.base_prefix probes, the venv interpreter's marker.txt read, python -m pip --version, and deactivate all run offline; without a supported Python, the exercise's recorded no-interpreter fallback applies.

    对比候选资源与选型分析 (2)
    pip documentation ↗ compared_alternative [MIT]

    Primary reference for pip commands, but the tutorial presents the create-activate-install loop as one beginner-friendly narrative.

    virtualenv documentation ↗ compared_alternative [MIT License]

    Mature third-party environment tool with overlapping behavior; the stdlib venv tutorial was selected to avoid an extra dependency for first-time setup.

    linking PSF License Version 2

    Python Standard Library: pathlib

    作者 / 机构: Python Software Foundation | 原始出处链接 ↗

    对应章节 / 时间戳: Path.exists, Path.cwd, and anchoring paths to __file__

    验证版本与日期: Python 3.12 (Verified: 2026-10-30)

    入选理由:

    Background reference for working-directory-relative file access: the Day 01 drill's venv interpreter reads marker.txt from the current directory using open(), not pathlib; Path.exists()/Path.cwd() evidence that separates an absent file from a wrong working directory is practiced on Study Day 10.

    来源前置条件:

    Basic Python syntax from Study Days 01-09

    安全回退方案(离线弹性):

    Not needed to complete the Day 01 drill, which makes no pathlib call, so no online page is required; Path.exists() and Path.cwd() are exercised offline on Study Day 10.

    对比候选资源与选型分析 (2)
    os.path documentation ↗ compared_alternative [PSF License Version 2]

    Functionally equivalent for exists() checks; pathlib keeps the beginner syntax object-oriented and consistent across the block.

    shutil — High-level file operations ↗ compared_alternative [PSF License Version 2]

    Covers copying and moving whole trees rather than path modeling; pathlib remains the right reference for the filesystem checks these days rehearse.

    150 min 独立掌握检查 (Independent Mastery Check)

    Git 核心概念:仓库初始化、提交与状态检查

    前置要求

    终端文件基础命令(mkdir, cd, ls)且 `git --version` 可用。

    学习目标

    独立初始化一个一次性 Git 仓库并完成 修改→暂存→提交→日志 循环,在每一步用 `git status`、`git diff`、`git log` 验证状态。

    操作指引

    受评估任务(独立完成):在新建的一次性目录中亲自完成全部流程;切勿在本项目或任何已有工作区内执行。不使用破坏性命令(reset --hard、clean、push --force)。若因缺少作者信息导致提交失败,按示例仅在该仓库内设置。

    mkdir git-sandbox && cd git-sandbox
    git init
    git config user.name "Learner"
    git config user.email "[email protected]"
    printf 'first line\n' > notes.txt
    git status
    git add notes.txt
    git diff --cached
    git commit -m "Add notes file"
    printf 'second line\n' >> notes.txt
    git status
    git diff
    git add notes.txt
    git commit -m "Append a second line to notes"
    git log --oneline
    git status

    期望不变量:
    - git add 之前 git status 将 notes.txt 列为未跟踪(untracked);暂存后 git diff --cached 显示以 + 开头的新增行。
    - 修改后 git status/git status --porcelain 显示文件为未暂存的修改( M),git diff 显示未暂存差异。
    - git log --oneline 按新到旧列出两条提交;最后的 git status 报告工作区干净。
    - 不带 --global 的 git config user.name/user.email 只写入该仓库的 .git/config,不改动整机配置。

    将每条命令与实测输出记入日志。

    可选且不计入评估的参观(不属于本检查):可以打开 Agent 工具路线页面,预览之后将使用的 Agent 工具。这仅是参观,不是本次独立掌握检查的一部分,也不构成其证据。

    自主演练与记录

    在新建空目录中执行上述完整命令序列。受评估的成果物是一份命令与输出记录,展示 notes.txt 的 未跟踪→已暂存→已提交 流转、第二轮 修改→暂存→提交,以及最终列出两条提交的 git log --oneline。另请记录一条 status 观察:可以是 git status 报告中与你预期不同的内容;若没有任何意外,则写下一个符合预期的状态转换、它的实际输出,以及该输出为何印证了你的预测。原始的预测和输出须原样保留。

    独立掌握标准:

    在一次性目录中独立完成完整流程——初始化新仓库、修改文件、暂存、核对暂存差异、提交、用 `git log --oneline` 确认两条提交并以干净的 `git status` 收尾;不依赖任何既有仓库状态,不使用破坏性命令,不借助 Agent 辅助。

    权威源资源与权利证明

    linking CC BY-NC-SA 3.0 noncommercial share-alike

    Pro Git, Second Edition

    作者 / 机构: Scott Chacon and Ben Straub | 原始出处链接 ↗

    对应章节 / 时间戳: Chapter 3 (Git Branching), Section 7.7 (Reset Demystified), Sections 5.2/6.2 (Contributing to a Project)

    验证版本与日期: Second edition (Apress, 2014) (Verified: 2026-10-30)

    入选理由:

    Freely licensed reference for branching, merging, conflict resolution, and safe recovery vocabulary used on Day 14.

    来源前置条件:

    Basic git status/log/diff vocabulary from earlier study days

    安全回退方案(离线弹性):

    git help <command> and the Git manual pages ship with Git and cover the same commands offline; every required workflow is stated locally in the lesson.

    对比候选资源与选型分析 (2)
    GitHub Skills interactive courses ↗ compared_alternative [MIT (varies by course)]

    Interactive but requires a GitHub account and an external service; disposable local repositories keep the exercise self-contained.

    Atlassian Git Tutorials ↗ compared_alternative [All Rights Reserved]

    Vendor-owned prose with no permissive license; Pro Git covers the same ground under CC BY-NC-SA.

    120 min 独立掌握检查 (Independent Mastery Check)

    首日复盘:提取练习、学习日志与认知对齐

    前置要求

    完成今日前 3 项活动。

    学习目标

    闭卷用自己的话写出今日关键概念,依据证据纠正一个误解(若未发现误解,则明确记录"未发现"并用证据否定一个常见误解),并安排具体的补救步骤,形成提取日志。

    操作指引

    合上课程与笔记,独立完成。
    第一步——独立回忆(合上所有参考资料):不查任何资料,写下你对今天三条主线的记忆——对象引用与可变修改、虚拟环境隔离、Git 的 修改→暂存→提交 循环。
    第二步——对照检查与纠正:现在才打开参考答案,标出回忆错误或遗漏之处,并按量规处理一个误解。不要改写第一步的文字,用批注方式标注,使独立回忆保持可区分。
    第三步——新的独立检查(再次合上参考资料):把纠正或回忆起的一个概念应用到新的小例子上(预测新代码的输出或重新推导一个检查),并记录结果。
    第四步——安排短时补救:确定在开始 Day 02 之前重测最弱项的具体时间与触发条件。

    量规——你的日志须满足全部四项:
    - 在独立回忆阶段用自己的话复述至少两个 Day 01 概念,而非照抄原文;
    - 记录一个真实误解及纠正它的具体证据,成对出现;若确实没有发现误解,则明确写出“未发现误解”,并举出一个常见的合理误解、用证据加以否定;
    - 记录第三步新的独立迁移/提取检查及其结果(只声称“全部正确”不能证明任何事);
    - 安排一个有具体时间和触发条件的补救步骤。
    篇幅不是证据:满足量规的短日志优于冗长总结。

    自主演练与记录

    按说明撰写提取日志:先独立回忆,再做对照纠正(或明确的“未发现误解”替代路径),随后完成新的独立检查并安排补救步骤。

    独立掌握标准:

    产出满足全部量规项的闭卷提取日志:用自己的话复述至少两个 Day 01 概念;一个真实误解及其纠正证据,或明确的“未发现误解”记录加一个用证据否定的常见误解;一次记录结果的新独立迁移检查;一个已安排的补救步骤。字数与空泛的正确性声明都不是概念掌握的证据。

    权威源资源与权利证明

    linking Journal publisher copyright (all rights reserved) - lawful external linking only

    Test-Enhanced Learning: Taking Memory Tests Improves Long-Term Retention

    作者 / 机构: Henry L. Roediger III, Jeffrey D. Karpicke | 原始出处链接 ↗

    对应章节 / 时间戳: Psychological Science 17(3): 249-255, Experiments 1-2

    验证版本与日期: Psychological Science, 2006 (Verified: 2026-10-30)

    入选理由:

    Foundational experimental evidence that retrieval practice (testing) outperforms repeated study for long-term retention; grounds the Day 88 AI-free retrieval checks in peer-reviewed learning science rather than folk advice.

    来源前置条件:

    Basic understanding of study sessions, retention intervals, and experimental design vocabulary.

    安全回退方案(离线弹性):

    The curriculum restates the experimental design and effect sizes in original prose; every sealed task runs without the paper.

    对比候选资源与选型分析 (2)

    Strong meta-analytic coverage of spacing effects but addresses scheduling rather than the retrieval effect itself; retained as support for the Day 90 spaced-review schedule.

    Equally foundational follow-up demonstrating repeated retrieval vs repeated study; the 2006 paper is cited as the standard first controlled demonstration.

    linking Journal publisher copyright (all rights reserved) - lawful external linking only

    Improving Students' Learning With Effective Learning Techniques: Promising Directions From Cognitive and Educational Psychology

    作者 / 机构: John Dunlosky, Katherine A. Rawson, Elizabeth J. Marsh, Mitchell J. Nathan, Daniel T. Willingham | 原始出处链接 ↗

    对应章节 / 时间戳: Psychological Science in the Public Interest 14(1): 4-58; practice testing and distributed practice sections

    验证版本与日期: Psychological Science in the Public Interest, 2013 (Verified: 2026-10-30)

    入选理由:

    Detailed comparative review rating practice testing and distributed practice as high-utility techniques while rating highlighting and rereading low-utility; anchors the retrieval, correction, and spaced-review design of Days 88-90.

    来源前置条件:

    None beyond general academic reading.

    安全回退方案(离线弹性):

    Curriculum restates the utility ratings and application conditions in original prose; every task remains runnable offline.

    对比候选资源与选型分析 (2)
    Pashler et al. Learning Styles: Concepts and Evidence ↗ compared_alternative [Publisher copyright (originally Wiley; now SAGE Publications)]

    Important negative result on learning-styles matching but narrower scope; Dunlosky et al. rates a broader set of techniques directly usable for this curriculum.

    Brown, Roediger & McDaniel: Make It Stick: The Science of Successful Learning ↗ compared_alternative [Publisher copyright (Harvard University Press)]

    Strong trade-book synthesis of the same evidence base; the peer-reviewed review is preferred for citation precision and technique-by-technique utility ratings.