Completing the Toolkit
Five Kinds of Bugs
James runs his modified program and gets an error. "It's broken," he says. "I'll just ask AI to fix it."
Emma stops him. "Before you do, what kind of problem is it?"
"Does it matter? AI will fix it either way."
"Try something first," Emma says. "Ask AI to fix it, but before you accept the fix, predict what AI will change."
James asks AI to fix the error. The fix appears: a single character change. He stares at it. "It added str() around the number. That's a type problem. The + couldn't join text with a number." He looks at the error message again. "The error message literally says TypeError. I could have found that myself."
"Now you know what to look for next time," Emma says. "And next time, you'll find it faster because you know the name for it."
When your code does not work, the first question is: what kind of problem is this? Knowing the kind tells you where to search. You do not need to memorize this table now. You will practice finding each kind starting in Chapter 45.
| Kind of Bug | What Went Wrong | Simple Example |
|---|---|---|
| Type Error | You gave the wrong kind of data | You wrote name + score but score is a number, not text |
| Logic Error | The code runs but gives the wrong answer | You printed the name where the subject should be |
| Specification Error | The code does what you asked, but you asked for the wrong thing | You built a greeting program when the task was a profile card |
| Data Error | The code breaks with unusual inputs | The name is empty, so the output starts with a space |
| Orchestration Error | The pieces run in the wrong order | You tried to print result before you created it |
When something goes wrong, just asking "Is this a type problem or a logic problem?" narrows your search and saves time.
Parsons Problems
Emma shows James four lines of code, but they are in the wrong order. "Put these back in the right sequence," she says.
James stares at them. He knows what each line does from the program he traced earlier. But arranging them correctly requires something deeper: understanding why the order matters.
A Parsons problem gives you the correct lines of code in scrambled order. Your job is to rearrange them into a working program. This tests whether you truly understand the program's structure, not just what it does, but why the lines must go in a specific order.
Try this one:
# These four lines are scrambled. What is the correct order?
print(label)
temp = 32
label = city + ": " + str(temp) + "C"
city = "London"
Reminder:
+joins text together.str()converts a number to text so+can use it.
Output (when correctly ordered):
London: 32C
Hint
Think about which variables must exist before other lines can use them. Which line creates a value that no other line depends on?
Answer
city, then temp, then label, then print. The reasoning: city must exist before label can use it, temp must exist before label can use it, and label must exist before print can display it.
You will see Parsons problems in later chapters as a bridge between Investigate and Modify. They check your structural understanding before you attempt free modifications. Your AI assistant can also generate fresh Parsons problems from any program you have studied. Just ask it to scramble the lines and quiz you.
What Every Chapter Looks Like
Starting in Chapter 45, every programming lesson follows the same Predict, Run, Investigate, Modify, Make pattern you practiced in Lessons 1 and 2. The structure stays the same; only the code gets harder.
Try With AI
Prompt 1: Classify Bug Types
I am learning the five kinds of bugs: Type Error, Logic
Error, Specification Error, Data Error, and Orchestration
Error. Show me three short broken Python programs (using
only variables and print). For each one, ask me to identify
what kind of bug it is before showing me the fix.
What you are learning: Diagnostic vocabulary. When you can name the kind of bug, you know where to search for the fix. This becomes critical when debugging AI-generated code.
Prompt 2: Generate a Parsons Problem
I am learning about Parsons problems. Generate a short
Python program (4-6 lines, using only variables and print).
Then scramble the lines and present them to me in random
order. Ask me to put them back in the correct sequence.
After I answer, tell me if I got it right and explain
why the order matters.
What you are learning: Parsons problems test structural understanding. The scrambled lines force you to reason about data flow: which variables must exist before others can use them.
Prompt 3: Walk Through All Five Steps
Walk me through a complete PRIMM-AI+ lesson. Show me a
short Python program (4-6 lines, using only variables
and print). At each step, tell me which step we are on
(Predict, Run, Investigate, Modify, Make) and what I
should do. Start by showing the code and asking me
to predict.
What you are learning: How the five-step lesson pattern feels in practice. By experiencing all five steps with AI guiding the process, you will recognize the pattern immediately when you encounter it in Chapter 45.
James closes his notebook. "Five kinds of bugs so I know what I'm looking for. Parsons problems to test whether I really understand the order. And every chapter follows the same five steps." He pauses. "It's like an SOP. Standard operating procedure. When I ran distribution centers, we had SOPs for every process. New hires never had to wonder what to do next."
"After two chapters, the five-step rhythm becomes invisible," Emma says. "You stop thinking about predict, run, investigate, modify, make. You just do it."
"So what comes next?" James asks.
"The ten axioms," Emma says. "Professional principles for building software with AI. You'll learn them the same way: predicting, investigating, and eventually writing programs that embody them."