Sub topic 1
Why Working Code Is Not the Same as Learning
Prerequisites
This chapter assumes basic programming knowledge: variables, functions, conditionals, and loops. You should also be able to run a script and a simple test.
Why Working Code Is Not the Same as Learning
An AI can produce code that runs before you understand the problem, the design, or the solution. A successful run proves that the program produced an output. It does not prove that you can recreate, explain, modify, or debug it.
Learning requires a usable mental model. You need to know what each part does, why it is needed, and when the same idea applies elsewhere.
How Programming Skill Develops: Practice, Struggle and Retrieval
Programming skill develops through repeated cycles:
- Try to solve a problem.
- Notice where your reasoning fails.
- Get a small amount of help.
- Fix or explain the solution.
- Retrieve the idea later without help.
This productive struggle exposes gaps that a finished answer can hide. Retrieval practice means recalling an idea from memory instead of only recognizing it in someone else's code. Prediction strengthens both skills.
def count_vowels(text):
return sum(1 for ch in text.lower() if ch in "aeiou")
# Predict the output before running this line.
print(count_vowels("Learning with AI"))Before running the code, predict the result and explain why. Then compare your prediction with the output.
Choosing a Role for the AI
Choose the least powerful role that supports your next learning step.
| Role | Useful request | Main risk |
|---|---|---|
| Tutor | Ask a question or give a hint | Progress may feel slow |
| Reviewer | Identify gaps in your code or tests | You may accept feedback uncritically |
| Generator | Produce a complete example | You may skip the reasoning |
Use generation when you need a reference after making your own attempt, not as your default first move.
Try First, Then Ask: An Attempt-First Workflow
Write a short plan and attempt the problem before asking for code. Record your expected output. If you are stuck, show your attempt and ask for one hint, one question, or an explanation of a specific concept. After revising, explain the solution in your own words and test edge cases.
Exercise
You need to write a function that returns the largest value in a list. What should you do before asking an AI for a solution?
Show answer
Write a plan and your own attempt, predict its behavior, then ask for a hint or review rather than the full solution.