Ask a vague question, get a vague answer
Ask a friend "what should I eat?" and you get "food". Ask "what can I cook in ten minutes with eggs and rice?" and you get a plan.
A generative AI tool is the same. A vague request gets code that only partly fits. A clear request, checked and improved, gets code you can really use. Activity C marks how well you do that.
Key words
| Word | What it means |
|---|---|
| Generative AI | A tool that writes text or code from a request. |
| Prompt | The request you type into the AI tool. |
| Snippet | A short piece of code that does one job. |
| Function | A named block of code that does one job and can give back a result. |
| Refine | To improve something a little at a time. |
| AI log | Your record of each prompt, the code back, your review and your changes. |
The cells students fill in are left blank in this preview.
By the end of this lesson
Note
I can refine a prompt and record my review of the AI's code in a log.
Starter: last lesson
Have a go
Starter: last lesson
3 questionsPick up to five real problems
Activity C is the only part of Task 1 where AI is allowed. You use it for small snippets, never a whole app.
Choose at most five problems. Each one should be a real piece of your Netheret solution. Pick a spread: some back end, some front end, some about data. Harder problems that link to other parts show more skill than five simple forms.
Worked example: five problems for Netheret
| Problem | Epic (area of the backlog) | Side | Language |
|---|---|---|---|
| Make the next reference, such as NTH-0042 | E2 Support requests | Back end | Python |
| Refuse a job that clashes with the engineer's other jobs | E3 On-site jobs | Back end | Python |
| Average time to resolve, for each priority | E5 Insights | Back end, data | Python |
| Check a company phone number and email address | E1 Accounts and access | Both | Python |
| Draw a bar chart of open requests by priority | E5 Insights | Front end | JavaScript |
The cells students fill in are left blank in this preview.
Check: choosing problems
Have a go
Check: choosing problems
3 questionsA precise prompt names the details
A good prompt is short but exact. Say the language and the tools. Say what goes in and what must come out. Give the rules and the awkward cases. Say what you do not want.
Each time the code is not right, change the prompt to fix that exact gap. Your log shows each version, so a marker can see your prompts getting sharper.
Worked example: three versions of one prompt
| Version | Prompt | What was still wrong |
|---|---|---|
| 1 | Write python for ticket numbers. | No format. Gave NTH-42, not NTH-0042. Crashed with no tickets. |
| 2 | Write a Python 3 function next_reference(last_reference). It takes the last reference, such as "NTH-0041", and gives back the next one, "NTH-0042". | Still crashed when there are no tickets yet. |
| 3 | As version 2. If last_reference is None, give back "NTH-0001". Always use four digits. Standard library only. Add one short comment per step. | Nothing in the function. We still had to add where it is called. |
The cells students fill in are left blank in this preview.
Check: prompts
Have a go
Check: prompts
3 questionsReview the code line by line
Never paste AI code in and move on. Run it. Test normal values, edge values and wrong values. Read each line.
Write positives and negatives that are specific. "It works" is not a review. "It gives NTH-42 because the number is not padded to four digits" is.
Check safety too: is input checked, and is stored data read and written safely? Then say what you will change: a new prompt, or an edit by hand.
A common mistake
Warning
Many students think AI code is right if it runs. Running only shows there is no crash. Code can run and still give a wrong answer, miss a case or be unsafe. Test it with your own values, read every line, and write what you found in the log.
Your turn: review and fix the AI code
An AI tool wrote next_reference from a vague prompt. Run it with the values in the comment and note what goes wrong. Then fix it: handle no tickets yet, and always use four digits. Write one positive and two negatives you found, as you would in the log.
def next_reference(last_reference):
# An AI tool wrote this from the prompt "write python for ticket numbers".
# Review it, then fix it so that:
# next_reference("NTH-0041") gives "NTH-0042"
# next_reference("NTH-0009") gives "NTH-0010"
# next_reference(None) gives "NTH-0001" (no tickets yet)
number = int(last_reference[4:]) + 1
return "NTH-" + str(number)
Make a free account to save your work, or press Start lab to work through the whole lesson.
Worked example: one AI log entry
| Log part | Entry for problem 1, version 1 |
|---|---|
| Problem | Make the next reference, such as NTH-0042 (E2.1) |
| Prompt | Write python for ticket numbers. |
| Positives | Short. Reads the number after "NTH-" and adds 1 correctly. |
| Negatives | No padding, so 42 shows as NTH-42. Crashes on None when there are no tickets. |
| Refinement | New prompt with the format and the empty case (version 2). By hand: renamed a name in the code to match our data design. |
The cells students fill in are left blank in this preview.
Where the snippet fits in the app
# app.py (shown, not run): the reviewed snippet inside a Flask route
@app.route("/requests/new", methods=["POST"])
@login_required
def raise_request():
last = Ticket.query.order_by(Ticket.id.desc()).first()
ticket = Ticket(
reference=next_reference(last.reference if last else None),
title=request.form["title"].strip(),
status="new",
tier=1,
)
db.session.add(ticket)
db.session.commit()
return redirect(url_for("request_detail", ticket_id=ticket.id))
Make a free account to save your work and track your progress.
Your turn: an AI log for one problem
Choose one problem from the worked example, or one of your own from your decomposition. If your teacher allows an AI tool in class, use it; if not, write the prompts and review the code your teacher gives you. Record at least three versions. For each: the prompt, a short summary of the code back, specific positives, specific negatives, and the refinement. Include at least one change you made by hand. Finish with two sentences on how the snippet will fit into the Netheret app.
A teacher marks this in a college. Nothing you write here is kept: it goes when you leave the page.
Make a free account to save your work, or press Start lab to work through the whole lesson.
Exit quiz
Have a go