A helper that can be wrong
Imagine a helper who writes code very fast. They never get tired. But sometimes they sound sure and they are wrong.
That is generative AI. It can write a short piece of code for you. You must still check it. You are the developer. The helper is only a tool.
Key words
| Word | What it means | Example |
|---|---|---|
| Generative AI | A tool that writes text or code when you give it a prompt. | a chat assistant |
| Prompt | The words you give the AI to say what you want. | Write a Python function that ... |
| Snippet | A short piece of code for one job. | one function |
| Review | Checking something carefully and deciding if it is good. | run it and read it |
| Design | A plan of how the solution will work, made before building. | screens and steps |
| Algorithm | A list of steps that solves a problem. | steps to join a waiting list |
| Flowchart | A diagram of steps with arrows. | start, check, book |
| Library | Code other people wrote that you can use. | pandas |
| Function | A named piece of code that does one job. | next_in_line() |
| Interface | What the user sees and uses. | a form |
The cells students fill in are left blank in this preview.
What a design pack holds
| Part | What it shows | Hillside example |
|---|---|---|
| Interface design | The screens the user will see | A "Join the waiting list" button and a list |
| Algorithm design | The steps for the key problems | A flowchart for moving the first person up when a booking is cancelled |
| Data design | What is stored, and in what form | A waiting list file with member, court, hour |
The cells students fill in are left blank in this preview.
Which part of the design does the job?
Have a go
Which part of the design does the job?
6 questionsAn algorithm: a cancelled court
flowchart TD
a([A booking is cancelled]) --> b[Remove the booking]
b --> c{Is anybody waiting for this court and hour?}
c -->|no| z([End: court stays free])
c -->|yes| d[Take the first person in the line]
d --> e[Book the court for them]
e --> f[Remove them from the waiting list]
f --> g[Tell them]
g --> z2([End])
Task 1 practice: draw a flowchart
Algorithm design practice. A member gives a rating after they play. Finish the flowchart. The rating must be a whole number from 1 to 5. If it is not, ask again. If it is, save it and say thank you. Add the missing steps and arrows.
flowchart TD
a([Member finishes a game]) --> b[Ask for a rating from 1 to 5]
b --> c{Is it a whole number from 1 to 5?}
Make a free account to save your work, or press Start lab to work through the whole lesson.
A good prompt is a clear brief
A weak prompt gets a weak answer. Say clearly what you want:
- The language and version.
- The job of one function.
- What goes in and what comes out.
- An example.
- Limits, such as "use no libraries".
Ask for one small function. Do not ask the AI to build the whole tool.
A weak prompt and a strong prompt
| Weak | Strong |
|---|---|
| Make a waiting list | Write a Python 3.10 function join_waiting_list(waiting, member, court, hour). waiting is a list of dictionaries. Add the member and return their place for that court and hour. Return 0 if they are already waiting. Use no libraries. |
| Fix my code | This function should return 0 for a repeat member. It returns 2. Here is the code and the test. What is wrong? |
The cells students fill in are left blank in this preview.
Check: prompts and AI code
Have a go
Check: prompts and AI code
5 questionsCheck AI code before you trust it
Warning
Never paste real names or phone numbers into a prompt. Run the code. Read every line. Test unusual cases, such as an empty list. Write down what the AI gave and what you changed. AI code may come from other people's work, so check any licence (the rules for using it). Ask your lecturer which AI tool to use.
Task 1 practice: review the AI code
Task 1 practice. An AI tool wrote this function. Read it and run the tests. It has two problems. Find them and fix them. Then, in a comment above the function, write one line for each problem. Press Run Tests to check your work.
def join_waiting_list(waiting, member, court, hour):
# An AI tool wrote this. Check it, then fix it.
# waiting is a list of dictionaries: {"member": ..., "court": ..., "hour": ...}
# Add the member to the list and give back their place in the line for that court and hour.
# Place 1 means first. Give back 0 and add nothing if the member is already waiting for the same court and hour.
for one in waiting:
if one["member"] == member:
return 0
waiting.append({"member": member, "court": court, "hour": hour})
return len(waiting)
Make a free account to save your work, or press Start lab to work through the whole lesson.
Task 1 practice: write a prompt log
Write a prompt for one function of the Hillside tool. The function is called next_in_line. It gives the name of the first member waiting for a court and hour, or None. Make it a strong prompt: language, job, inputs, output, example and limits. Then make a table with four columns: What I asked, What the AI gave (or what you expect), What I checked, What I changed. You do not need a real AI tool for this practice. Ask your lecturer which tool to use in the live task.
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.
Key words crossword
Have a go
Loading…
Your answers are marked here and are not kept. A college account keeps every student’s marks.
Final check
Have a go