How to Teach Python Using Spec-Driven Development
About this translation
Original publication dates and historical context are preserved. Images, embedded media, source documents and code examples remain in their original language.

Programming education · Methodology
Learning Python usually starts the same way: variables, data types, conditionals, loops, functions, and, after several sessions, a practical project. The problem is that this approach forces students to learn the syntax first and only later understand what it is for.
An interesting alternative is to reverse the process through Spec-Driven Development (SDD) or development guided by specifications.
The sequence
Problem → Specification → Code → Test → Correction
Instead of starting by asking “How does a if work in Python?”, we start by asking:
What exactly should the program do?
This seemingly small change can make learning programming much more intuitive, especially for people with no previous background in software development.
What is Spec-Driven Development?
Spec-Driven Development proposes having a sufficiently clear specification of the system's expected behavior before writing code. A simple specification should answer at least five questions:
- 1What problem should it solve?
- 2What information does it receive?
- 3What rules should it apply?
- 4What result should it deliver?
- 5How will we verify that it works correctly?
For example, imagine we want to develop a small program to track achievement of a sales target. The specification could be:
Before writing a single line of Python, the student already understands what should happen.
From specification to code
Once the specification is defined, we can progressively turn it into Python.
Several fundamental programming concepts arise naturally here:
- —variables
- —numbers
- —mathematical operators
- —comparisons
- —conditionals
- —information output
The difference is that every concept now has a reason to exist.
The student learns an if because they need to implement a rule they previously defined, not because it appears in chapter four of the course.
Teaching Python through needs, not syntax
This approach allows an introductory programming course to be completely reorganized.
| Need | Python concept |
|---|---|
| Store information | Variables |
| Perform calculations | Operators |
| Apply rules | if, elif, else |
| Process many records | for |
| Store multiple items | Lists |
| Represent records | Dictionaries |
| Reuse logic | Functions |
| Read files | Pandas |
| Handle errors | Exceptions |
| Verify behavior | Tests |
Syntax stops being the starting point and becomes a tool for solving something.
An example: learning loops without starting by explaining loops
Suppose we have a list of sales transactions:
The specification states:
A natural question now arises: How do we apply the same rule to every transaction? At that point, the concept of iteration appears.
The student has just learned a for, and did so to address a specific need.
SDD also changes the role of artificial intelligence
The emergence of tools such as ChatGPT, Claude, Gemini, and GitHub Copilot introduces a new challenge in teaching programming. Today a student can ask “Make me a Python program that analyzes sales” and receive hundreds of lines of code in seconds.
That is why evaluating only the ability to write code is starting to lose relevance. SDD changes the dynamic: the student takes on three responsibilities.
|
01 Specify Correctly define the problem, inputs, rules, and outputs. |
02 Generate or implement Build the code directly or use an AI tool for a first version. |
03 Verify Check that the result actually meets the specification. |
This changes the relationship between the student and AI. AI stops being merely a machine that “does the homework” and becomes an implementation assistant. Judgment remains with the student.
A simple classroom rule
One particularly useful practice is to establish a rule:
No code is generated until a verifiable specification exists.
Before opening the Python editor, the student must complete five blocks:
This structure forces students to think before programming and helps teachers quickly identify where the problem lies. If the program produces an incorrect result, we can ask:
- —Was the specification incorrect?
- —Was the rule incomplete?
- —Did the code implement the rule incorrectly?
- —Were test cases missing?
This leads to much more valuable conversations than simply correcting syntax errors.
A possible learning path
An introductory Python course based on SDD could be organized into eight sessions.
| S1 |
From problem to specification Identify objectives, inputs, rules, outputs, and acceptance criteria. |
| S2 |
From specification to Python Variables, data types, operators, and results. |
| S3 |
Decision rules Using |
| S4 |
Processing multiple data items Lists, dictionaries, and loops. |
| S5 |
Building functions How to turn repetitive rules into reusable components. |
| S6 |
Real data Reading and processing CSV or Excel files using Pandas. |
| S7 |
Validation Test cases, errors, |
| S8 |
Complete project Building a solution from the specification through final testing. |
The result is a different progression: problem → logic → implementation → validation.
What changes for the student
With this approach, learning Python stops meaning memorizing commands. Students begin to develop other abilities:
|
|
These skills are especially important in a context where more and more code can be generated automatically.
Programming is no longer just about writing code
For many years, learning programming meant learning to produce instructions for a computer. Artificial intelligence is partially changing that definition: it will become increasingly common for a person to describe an expected behavior and for a tool to generate part of the implementation.
In that scenario, knowing how to specify a problem correctly becomes a core competency. That is why teaching Python through Spec-Driven Development can be a particularly useful way to introduce programming to new students.
Instead of starting the class with “today we will learn variables,” we can start with something much closer to reality:
“We have a problem. Let's define exactly what the program should do.”
And from there, let Python appear as what it really is: a tool for turning a well-defined idea into an executable solution.