07 / 90

Day 07: Weekly review — values, conditions, and safe Git

A lower-new-content review day: retrieve Days 04–06 (values and bindings, comparisons and explicit conditions, small diffs and commits) from memory with fresh inputs, then check yourself independently. The only new items are one scaffolded command (git restore) and a short, unassessed preview of Day 08's for loop. Retrieval, review, and the independent check fill the 480-minute ledger.

Self-Directed Learning & Python 480 active minutes (8 hours focused study)
01 120 min

Closed-book retrieval: values and bindings (Days 04–05)

Agent-assisted practice: write your own prediction and observed output first; only then may you ask an AI agent to explain or review, and you must record that assistance in your evidence.

Prerequisites

Day 06 completed, including its independent check. If blocked, recover with Day 06 first; for values and bindings, revisit Days 04–05.

Learning Objective

Recall from memory how repr, type, and bool describe a value, and how rebinding differs from mutation, then confirm with Python on inputs you have not seen before (including empty and Unicode text).

Instructions

Spaced review: Days 04–05 were two to three days ago, so today you retrieve them before rereading anything. Pulling an idea back from memory, then checking it, makes it last longer than rereading notes. Nothing in this activity is new.

1. Close your notes. For each value in the first snippet, write the three columns you expect: repr, type name, and bool. Also predict the last line (len counts Unicode code points, not bytes).
2. Run the snippet and mark every row where your prediction differed.
3. Repeat with the binding snippet: predict both lines, then run it.
4. For each mismatch, write one sentence naming the rule you forgot and the day that teaches it (Day 04 for values, Day 05 for mutation and identity).

def show(value):
    print(repr(value), type(value).__name__, bool(value))
show(0.0)
show("0.0")
show("")
show("猫")
show([""])
show(None)
print(len("猫"), len("café"))
a = ["猫"]
b = a
a.append("犬")
print(b, a is b)
c = ["猫"]
d = c
c = c + ["犬"]
print(d, c is d)

Practice & Prediction Log

Record a prediction table with one row per value (0.0, "0.0", "", "猫", [""], None) and the columns repr / type / bool, plus your prediction for len("猫") and len("café"). Then predict the two lines printed by the binding snippet and explain which name was mutated and which was rebound.

Independent Mastery Criterion

Your written predictions exist before execution, cover all six values plus the two len results and both binding lines, and every mismatch has a one-sentence rule and a recovery day (Day 04 or Day 05).

Authoritative Source Resources & Provenance

linking PSF License Version 2

The Python Tutorial: More Control Flow Tools

Author: Python Software Foundation | Original Source Link ↗

Relevant Section / Range: Sections 4.2–4.10 (for, range, defining functions); data structures are in Chapter 5 of the same tutorial

Verified Version & Date: Python 3.12 documentation; verified 2026-10-30

Selection Rationale:

Primary reference for Python iteration, functions, and containers.

Source Prerequisites:

Study Days 01-06 Python expression and filesystem fundamentals

Safe Fallback (Offline Resilience):

The lesson explains all required behavior locally and can be completed offline.

Compared Candidate Sources & Selection Analysis (2)
The Python Language Reference: Compound statements ↗ compared_alternative [PSF License Version 2]

Grammar-level definition of the same constructs; the tutorial chapter was selected for its guided pacing.

Lecture-paced coverage of the same control flow; deferred because the curriculum already drives the concepts through terminal drills.

02 120 min

Retrieval: comparisons and explicit conditions (Days 05–06)

Agent-assisted practice: write your own prediction and observed output first; only then may you ask an AI agent to explain or review, and you must record that assistance in your evidence.

Prerequisites

Today's activity 1. If comparisons feel unfamiliar, revisit Day 05; for conditions and input normalization, revisit Day 06.

Learning Objective

Recall the difference between == and is, and rebuild a Day 06-style classifier from memory that handles empty, whitespace-only, decimal, and Unicode-digit input with explicit conditions.

Instructions

Spaced review: this revisits Day 05 (comparisons) and Day 06 (conditions) with new inputs, so you cannot rely on remembered answers.

1. Predict the five booleans printed by the comparison line, then run it.
2. Without looking at Day 06, write label(raw): strip the text; return "missing" if the result is the empty string; return "number " plus the integer value if the stripped text is decimal; otherwise return "text " plus the stripped text. Predict the six printed lines before running your version.
3. Compare your function with the reference below and run both.

print(0 == 0.0, "0" == 0, None is None, [] == [], [] is [])
def label(raw):
    text = raw.strip()
    if text == "":
        return "missing"
    if text.isdecimal():
        return "number " + str(int(text))
    return "text " + text
print(label("  猫 "))
print(label(""))
print(label("   "))
print(label("007"))
print(label("-3"))
print(label("٣"))

Optional preview for Day 08 (not assessed, scaffolded): run the loop below and only observe that its body runs once per character. You will study loops properly tomorrow.

for ch in "猫a":
    print(ch, ch == "a")

Practice & Prediction Log

Write your five comparison predictions and your own label(raw), then predict the six outputs for " 猫 ", "", " ", "007", "-3", and "٣" (ARABIC-INDIC DIGIT THREE). After running, explain the surprising result for "٣".

Independent Mastery Criterion

All five comparison predictions and all six label predictions are written before running; your own label(raw) reproduces the reference output exactly; you can explain why " " is missing and why "٣" is a number.

Authoritative Source Resources & Provenance

linking PSF License Version 2

The Python Tutorial: More Control Flow Tools

Author: Python Software Foundation | Original Source Link ↗

Relevant Section / Range: Sections 4.2–4.10 (for, range, defining functions); data structures are in Chapter 5 of the same tutorial

Verified Version & Date: Python 3.12 documentation; verified 2026-10-30

Selection Rationale:

Primary reference for Python iteration, functions, and containers.

Source Prerequisites:

Study Days 01-06 Python expression and filesystem fundamentals

Safe Fallback (Offline Resilience):

The lesson explains all required behavior locally and can be completed offline.

Compared Candidate Sources & Selection Analysis (2)
The Python Language Reference: Compound statements ↗ compared_alternative [PSF License Version 2]

Grammar-level definition of the same constructs; the tutorial chapter was selected for its guided pacing.

Lecture-paced coverage of the same control flow; deferred because the curriculum already drives the concepts through terminal drills.

03 120 min

Safe Git review: inspect, check, commit, and restore an uncommitted edit

Agent-assisted practice: write your own prediction and observed output first; only then may you ask an AI agent to explain or review, and you must record that assistance in your evidence.

Prerequisites

Today's activities 1–2; Git installed. If git diff or a small commit feels unfamiliar, revisit Day 04 activity 3 and Day 06 activity 3.

Learning Objective

Rehearse the Days 04–06 safe-change loop (diff, diff --check, small commit, log) in a disposable repository, and use one new scaffolded command, git restore, to discard an uncommitted edit and verify the result.

Instructions

Spaced review: inspecting a diff before committing was practiced on Days 04 and 06; today you repeat it from memory in a fresh fixture. New today (scaffolded): By default, git restore FILE restores a tracked file in the working tree from the index (staging area); it does not change the index or unstage changes. In this fixture the index equals HEAD (the latest commit), so it discards the unstaged edit by restoring that committed version. It cannot undo a commit; Day 09 covers that.

Work only in a new temporary directory, never in the curriculum repository. Before each command, write what you expect it to print (an empty output counts as a prediction). Then run the whole sequence:

cd "$(mktemp -d)"
git init -q
git config user.name "Learner"
git config user.email "[email protected]"
printf 'label: 猫\n' > notes.txt
git add notes.txt
git commit -q -m "Add notes"
printf 'label: 猫\ncount: 1\n' > notes.txt
git diff --stat
git diff --check
git add notes.txt
git commit -q -m "Add count line"
git log --format=%s
printf 'oops\n' >> notes.txt
git status --short
git restore notes.txt
git status --short
cat notes.txt

Practice & Prediction Log

Record predictions for the output of git diff --stat, git diff --check, git log --format=%s, and both git status --short commands, then run the sequence and record the actual output. Finally, write the file contents after git restore and explain why the Unicode line "label: 猫" survived.

Independent Mastery Criterion

Predictions are recorded before running; the observed output matches the reference exactly; you can state when git restore is the right tool (uncommitted edit to a tracked file) and that it does not undo commits.

Authoritative Source Resources & Provenance

linking PSF License Version 2

The Python Tutorial: More Control Flow Tools

Author: Python Software Foundation | Original Source Link ↗

Relevant Section / Range: Sections 4.2–4.10 (for, range, defining functions); data structures are in Chapter 5 of the same tutorial

Verified Version & Date: Python 3.12 documentation; verified 2026-10-30

Selection Rationale:

Primary reference for Python iteration, functions, and containers.

Source Prerequisites:

Study Days 01-06 Python expression and filesystem fundamentals

Safe Fallback (Offline Resilience):

The lesson explains all required behavior locally and can be completed offline.

Compared Candidate Sources & Selection Analysis (2)
The Python Language Reference: Compound statements ↗ compared_alternative [PSF License Version 2]

Grammar-level definition of the same constructs; the tutorial chapter was selected for its guided pacing.

Lecture-paced coverage of the same control flow; deferred because the curriculum already drives the concepts through terminal drills.

04 120 min

Independent weekly check: Days 04–06

Independent mastery check: no AI assistance and no reference answer until your evidence is submitted; declare your assistance honestly.

Prerequisites

Today's activities 1–3 completed with recorded evidence. Recovery links: Day 04 (values), Day 05 (bindings and comparisons), Day 06 (conditions and safe Git).

Learning Objective

Without assistance, predict value, binding, and comparison results, implement a small explicit-condition function from scratch, and write the safe inspection commands from memory.

Instructions

Spaced review: this is the weekly consolidation check for Days 04–06. Do not open the reference answer or use AI until your evidence is submitted.

1. Predict, in writing, the three lines printed by this snippet, then run it:

print(repr("0"), bool("0"), "0" == 0)
x = ["a"]
y = x
x.append("é")
print(y)
x = ["a"]
y = x
x = x + ["é"]
print(y)

2. From scratch, write describe(raw): return "empty" when the stripped text is empty, "digits" when it is decimal, otherwise "text". Predict and then test it on "", " ", "42", "42" (full-width digits), and "猫".
3. From memory, list the commands you would run in a disposable repository to inspect a change before committing it, and the command that discards an uncommitted edit to a tracked file.

Practice & Prediction Log

Submit: your three snippet predictions and observed output; your describe(raw) code with five predictions and five observed results; your command list for safe inspection and restoring; and, for any mismatch, the recovery day you will revisit.

Independent Mastery Criterion

Unaided: all three snippet predictions are written first, describe(raw) passes all five cases including empty, whitespace-only, and full-width Unicode digits, the command list is correct, and each mismatch names a recovery day.

Authoritative Source Resources & Provenance

linking PSF License Version 2

The Python Tutorial: More Control Flow Tools

Author: Python Software Foundation | Original Source Link ↗

Relevant Section / Range: Sections 4.2–4.10 (for, range, defining functions); data structures are in Chapter 5 of the same tutorial

Verified Version & Date: Python 3.12 documentation; verified 2026-10-30

Selection Rationale:

Primary reference for Python iteration, functions, and containers.

Source Prerequisites:

Study Days 01-06 Python expression and filesystem fundamentals

Safe Fallback (Offline Resilience):

The lesson explains all required behavior locally and can be completed offline.

Compared Candidate Sources & Selection Analysis (2)
The Python Language Reference: Compound statements ↗ compared_alternative [PSF License Version 2]

Grammar-level definition of the same constructs; the tutorial chapter was selected for its guided pacing.

Lecture-paced coverage of the same control flow; deferred because the curriculum already drives the concepts through terminal drills.