Easier to read with cream paper, a tint, more contrast or larger text? Choose your colours and text, once, for every page.

Free lesson

Task 1 C: Generative AI for Netheret code, with a log

The whole lesson, free. Read it and have a go at the activities. To work the tasks and labs in the real lesson, press Start lab, with no account needed.

60 minutes

A quick check that you are not a bot, then your own lab opens on the interactive lesson.

Already have an account? Sign in

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

WordWhat it means
Generative AIA tool that writes text or code from a request.
PromptThe request you type into the AI tool.
SnippetA short piece of code that does one job.
FunctionA named block of code that does one job and can give back a result.
RefineTo improve something a little at a time.
AI logYour 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 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Pick 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

ProblemEpic (area of the backlog)SideLanguage
Make the next reference, such as NTH-0042E2 Support requestsBack endPython
Refuse a job that clashes with the engineer's other jobsE3 On-site jobsBack endPython
Average time to resolve, for each priorityE5 InsightsBack end, dataPython
Check a company phone number and email addressE1 Accounts and accessBothPython
Draw a bar chart of open requests by priorityE5 InsightsFront endJavaScript

The cells students fill in are left blank in this preview.

Check: choosing problems

Have a go

Check: choosing problems

3 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

A 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

VersionPromptWhat was still wrong
1Write python for ticket numbers.No format. Gave NTH-42, not NTH-0042. Crashed with no tickets.
2Write 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.
3As 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 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Review 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.

Code: python
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 partEntry for problem 1, version 1
ProblemMake the next reference, such as NTH-0042 (E2.1)
PromptWrite python for ticket numbers.
PositivesShort. Reads the number after "NTH-" and adds 1 correctly.
NegativesNo padding, so 42 shows as NTH-42. Crashes on None when there are no tickets.
RefinementNew 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

Code: python
# 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

Exit quiz

5 questions
Have a go: your answers are marked here and then forgotten. Sign in if you would like your score kept, and to pick up where you left off.Sign in to keep your score

Teach this lesson with your class

On a college account your students work the tasks and the labs as well, and every mark is kept for you.