Two people, one assistant
Two new developers at a delivery company ask the same assistant for help. One types "fix my date code". The other says what the code is for, pastes the error and shows one date.
The first gets a guess. The second gets a fix that works. The difference is not luck. It is how they asked.
By the end of this lesson
Note
I can write a clear request with context and an example.
Key words
| Word | What it means | Example |
|---|---|---|
| Goal | what you want the code to do | |
| Context | the facts the assistant needs about your work | |
| Constraint | a limit the answer must keep to | Use plain Python |
| Example | one input with the output you expect | 1250 gives 12.50 |
| Output format | the shape you want the answer in | |
| Follow-up | a next message that corrects or adds detail |
The cells students fill in are left blank in this preview.
A clear request has four parts
The assistant knows only what you tell it. So say four things.
The goal: what the code must do. The context: where the data comes from and what it looks like. The constraints: the language, the libraries, the style. The output format: one function, a whole file, or an explanation.
A vague request and a clear one
| Part | Vague | Clear |
|---|---|---|
| Goal | Fix my date code | Turn a date like 21/10/2026 into 2026-10-21 |
| Context | (missing) | Dates come from a delivery CSV file, day first |
| Constraint | (missing) | Python 3, no extra libraries |
| Output format | (missing) | One function, with a short comment |
The cells students fill in are left blank in this preview.
An example removes the guessing
Words can mean two things. "Format the price" could mean £12.50, 12.5 or 1,250p.
One example settles it. Give one input and the exact output you expect. Two or three examples are better when there is an odd case, such as zero or an empty list. Later, the same examples become your tests.
Try it: add an example
# A request for an assistant, kept as text in a script.
goal = "Write a Python function that turns a price in pence into pounds."
context = "Prices come from our shop's orders file as whole numbers."
limit = "Use plain Python. No extra libraries."
example = ""
# Add an example: give example the text
# "Input 1250, output 12.50" and press Run.
print("Goal:", goal)
print("Context:", context)
print("Limit:", limit)
print("Example:", example)
A follow-up says what was wrong
The first answer is often close but not right. Do not start again with the same words.
Send a follow-up. Say what you ran and what happened. Paste the exact error message. Add the constraint you forgot. Each message adds to the context, so the next answer has more to go on.
Worked example: three messages
| Message | What you send | Why it helps |
|---|---|---|
| 1 | Goal, context, constraint and one example | A clear start |
| 2 | It fails for 05/01/2026. Here is the error. | The exact fault is now in the context |
| 3 | Good. Now add a comment on each step. | One change at a time is easy to check |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think a longer request is always a better one. Length only helps when every line changes the answer. Keep the goal, the facts, the limits and an example, and cut the rest.