read the script
read the script
read the script
read the script
read the script
read the script
read the script
read the script
read the script
read the script
read the script
ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.ai hands you small scripts. this lab covers the three reads that matter: what the names hold, whether the function actually returns, and which branch of the if-chain really fires. if you are starting here, this labels the reads. if you already ran a studio, you already wrote these.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — a tool contract (the list of what an agent is allowed to call), a metered loop (a loop with step and cost caps), a CI triage agent (a helper that reads failing test jobs and decides rerun, issue, or page). This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — a voice pack, a batch plan, a numbers pass. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — art-director prompts, a design kit, a fifty-asset QA filter. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — a policy pack, golden evals, an escalation boundary. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — a voice fingerprint, on-voice variants, a claim check. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — a cleaning log, a traced memo, a challenge-then-rerun. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — a spec lint, acceptance checks, an hours-saved receipt. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — a data firewall, briefs with receipts, a paper trail. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — SOP lint, named-approval checklists, receipt gates, a PII proxy. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
Why a code-reading lab
If you are starting here, AI tools will hand you small scripts, formulas, workflows, and snippets all year — and if you cannot read the first five lines, you cannot stay in charge of the tool you asked for.
If you already ran a studio on this path, you already wrote Python — a cite-check, clause extraction, a privilege router. This lab
is the map of those reads: what the names hold, whether the function
actually returns, and which branch of an if chain really fires.
So this chapter is a lab, not a course. PromptDojo is not a syntax
school. The goal is: when AI gives you a tiny program, you can run it,
point at the important names, say whether the function actually hands
its answer back, and tell which branch of an if chain really fires.
Those three reads catch most of what AI gets wrong in small scripts.
The tiny mental model
A program needs names for things.
limit = 10
used = 7
remaining = limit - used
Read that like a note, not like math class:
limitis the number the tool is allowed to useusedis what already happenedremainingis the answer after subtracting one from the other
That is enough to begin. Everything else in this lab builds on reading lines like these and asking: what value does this name point to right now, and where does it go next?
What this lab covers in three lessons
Lesson 1: Names and values. The names a script uses, the few shapes
values come in (number, text, flag, None), and the one idea that trips
people once: = is a command, not a claim.
Lesson 2: Functions and the hallucinated return. AI writes functions
constantly, and the silently missing return is one of its
best-documented failure modes. The function does the work, computes the
answer — and never hands it back. The caller gets None and your code
fails three steps later. You'll learn to spot it on sight, and to tell
return from print, which AI mixes up when you ask it to "show the
result."
Lesson 3: Decisions — if/elif chains. if looks simple. The traps
inside it — 0 and empty values counting as false, == versus is,
branches ordered so the right one can never fire — are where AI quietly
ships wrong code. You'll fix each of those bugs by hand.
Where AI specifically gets this wrong
The bug list this lab trains you to catch:
- Name typos. A variable defined as
totaland used astotl—NameError, and the fix is one careful read. - The hallucinated return. The flagship bug. The function computes
the answer and drops it on the floor; the caller gets
None. printwherereturnbelongs. The value is visible on screen but not captured — nothing downstream can use it.- Truthy traps.
if score:treats a real score of0the same as "no score at all."if items:can't tell an empty list from a missing one. ==vsis. Both "work" in a quick demo; only one keeps working when the value arrives from a file or an API. The rule: use==for everything, useisonly forNone.- Branch order. An
if score >= 70placed aboveelif score >= 90means "excellent" can never fire. No crash, no warning — just silently wrong output.
What you'll be able to do at the end
Three lessons, 24 steps. By the end you will be able to:
- run a tiny AI-generated script and explain where each part of the output came from
- read a function definition and predict what calling it returns —
including when the answer is
None - spot the missing-return bug in thirty seconds of code review
- predict whether an
ifcondition fires on a given value, including the zero/empty/Noneedge cases - fix the wrong-order
elifchain that ships silently wrong results - use your own AI assistant as a syntax reference, with the verification habit that keeps it honest
Every later chapter assumes these three reads. Get them in your hands here and the rest of the curriculum reads like review.
Press Start chapter below.
lessons in this chapter
- names and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and valuesnames and values
- functions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated returnfunctions and the hallucinated return
- decisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chainsdecisions — if/elif chains