自學方法與 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.