Module 0: Orientation, Python with AI
The Learning Workflow: Read, Predict, Modify, Run, Debug, Explain
The six-step habit this course repeats in every lesson, and how to use it on AI-generated code you did not write.
Lesson 2 of 46 in the recommended order · About 20 min (estimate)
On this page
Outcome
By the end of this lesson you can apply a six-step habit, read, predict, modify, run, debug, explain, to a short program you have never seen before, and you can tell whether a question you are about to ask an AI assistant is really a request for an explanation or a request for a change to real files.
Why it matters
Every lesson in this course, starting with the last one, follows the same shape on purpose. Once the shape is automatic, you stop needing this course to make progress. You can apply it to any unfamiliar Python file, AI-generated or not.
Concept
The habit has six steps, always in this order:
- Read the whole thing once before touching it.
- Predict what it will do, out loud or in writing, before running it.
- Modify it in one small, deliberate way.
- Run it, or trace it by hand, and compare the real result to your prediction.
- Debug anything that does not match. Form a hypothesis, then check it.
- Explain, in your own words, what changed and why.
Step 6 is the one people skip. It is also the one that catches the difference between "it works" and "I understand why it works", and only the second one transfers to the next unfamiliar file.
Read the code
notice_id = "ABC-2026-0091"
status = "Active"
summary = f"{notice_id}: {status}"
print(summary)
Two names are created and bound to text values, a third name is built by combining them into one formatted string, and the last line prints that string. Nothing here depends on order except that each name must exist before it is used: summary needs both notice_id and status to already exist.
Predict the output
Predict the single line this prints, then check.
Check your prediction
ABC-2026-0091: Active
Modify the code
Apply step 3 of the workflow: make one small, deliberate change. Add a fourth line that reassigns status to "Closed" before the summary line, and predict how the output changes before you run it.
What changes and why
Because summary is built from whatever status holds at the moment that line runs, moving the reassignment earlier changes the printed output to ABC-2026-0091: Closed. If the reassignment came after the print(summary) line instead, the output would stay Active. Order matters.
Debug the bug
An AI assistant wrote the version below and claimed it prints the notice ID followed by "Closed".
notice_id = "ABC-2026-0091"
status = "Active"
summary = f"{notice_id}: {status}"
status = "Closed"
print(summary)
What's actually wrong
This is the "wrong output" case, not a crash: it runs cleanly and prints ABC-2026-0091: Active, not ...: Closed, because summary was already built and stored as a fixed string on line 3. Reassigning status afterward does not retroactively change summary. The claim was wrong, not the code; this is exactly the kind of confident but incorrect claim step 6 (explain) is meant to catch before you trust it.
Try it yourself
Now try it for real, in your browser. The starter code below sets up notice_id and status for a different opportunity than the one in Read the Code above. Add the line (or lines) that print both together, the same way that example did, then run it.
Loading this exercise…
AI collaboration
Checkpoint
A classmate says: "I ran the AI's code from the Debug the Bug section above and it printed Active, so the AI must have made a typo somewhere." Which workflow step did they skip, and what is the actual explanation?
Answer
They skipped step 6 (explain). The code has no typo and produced exactly what it was written to produce; the AI's claim about what it would print was wrong, not the code's syntax. Explaining why summary stayed "Active" (because it was built before status changed) is what separates "it ran" from "I understand what happened."
Sign in to track your progress on this exercise.
Summary and next step
You now have a six-step habit, read, predict, modify, run, debug, explain, and a first taste of separating "does it run" from "is the claim about it true." Module 1 puts this habit to work on values, variables, and expressions, and begins the SAM.gov opportunity-record thread that runs through the rest of the course.