Show contents
Chapter 4 of 6 · 20 min
Asking well and checking
By the end of this chapter, you'll be able to
- Structure a request with context, task, format and examples
- Improve an answer by continuing the conversation rather than starting over
- Check an answer with an independent source or a test
- Check code suggested by an assistant by running it on precise cases
The four ingredients of a good request
An effective request (also called a prompt) usually contains:
- the context: who you are, what you already know, what the answer will be used for;
- the task: what you want, with a precise action verb (explain, summarise, correct, suggest three ideas);
- the format: the length, the form (list, table, code), the register;
- examples or constraints: what you expect or what you refuse.
Here is a small function that assembles a request from these ingredients:
def request(context, task, format_, constraints=()):
lines = [f"Context: {context}", f"Task: {task}", f"Format: {format_}"]
lines += [f"Constraint: {c}" for c in constraints]
return "\n".join(lines)
print(request(
context="I'm in my final year of high school in Mali and I'm revising sequences in maths.",
task="Ask me 3 questions of increasing difficulty on arithmetic sequences.",
format_="One question at a time; wait for my answer before correcting.",
constraints=["Don't give the solution before my attempt", "Use examples with CFA francs"],
))
Context: I'm in my final year of high school in Mali and I'm revising sequences in maths.
Task: Ask me 3 questions of increasing difficulty on arithmetic sequences.
Format: One question at a time; wait for my answer before correcting.
Constraint: Don't give the solution before my attempt
Constraint: Use examples with CFA francs
You don't need to write "Context:" every time: what matters is that the four pieces of information are there.
You run the example: the result confirms the explanation.
Text description of the animation
- The request gives the level, the task and the expected format.
- The answer is good but uses a word you don't know: “iterable”.
- Rather than starting over, you continue the conversation: the assistant keeps the context.
- The new answer is suited to your level.
- You run the example: the result confirms the explanation.
Continue rather than start over
An assistant keeps the thread of the conversation. If the answer doesn't suit you, clarify instead of rewriting everything: "shorter", "with a Malian example", "you used a word I don't know", "redo the table with a column for prices". And if the conversation goes in the wrong direction, open a new one: the old mistakes will no longer pollute the answers.
Checking suggested code
For code, the best check is simple: run it on cases whose answer you know, including edge cases (zero, empty list, negative number…).
Mini-lab: test an assistant's codePython 3.13
Output
Click “Run”: Python will load in your browser (about 10 MB the first time).Your code runs in your browser, isolated from the page. · Ctrl/⌘ + Enter to run · Esc then Tab to leave the editor
Your turn
Worked exercise
Worked exercise: rewriting a request
Rewrite these three vague requests by adding a context, a precise task and a format:
1. "help me with my presentation"
2. "fix my code"
3. "explain photosynthesis"
Hint 1
Hint 2
Show the solution and common mistakes
1. "I'm preparing a 10-minute presentation for my Year 11 class on
the history of the Mali Empire. Suggest a 4-part outline with,
for each part, two ideas to develop. Don't write the presentation:
I want to write it myself."
2. "I'm new to Python. This program should print the average of my
grades, but it prints "ZeroDivisionError: division by zero".
[the code]. Explain why in two sentences, then show me only the
line to fix."
3. "I'm in Year 7. Explain photosynthesis in 5 simple sentences,
with a comparison from everyday life, then ask me one question
to check that I understood."
Common mistakes:
- Forgetting the level: without it, the assistant picks a vocabulary at random, often too technical.
- Asking "do my presentation": you get a text you don't master, which may contain errors, and which your teacher may consider cheating.
- Pasting code without the error message: the assistant then has to guess the problem.
Summary
- 1A good request states the context, the task, the format and the constraints.
- 2Improve an answer by clarifying in the same conversation, and open a new one if it goes astray.
- 3Information is checked in an independent source, not by asking the assistant again.
- 4Suggested code is tested on known cases and edge cases before being used.
- 5Giving the exact error message and your level makes help much more useful.
Your progress is saved on this device. Create a free account to keep your progress on all your devices.