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

Free lesson

OSP task 1 (1 of 3): Design the solution and use AI wisely

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.

45 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

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

WordWhat it meansExample
Generative AIA tool that writes text or code when you give it a prompt.a chat assistant
PromptThe words you give the AI to say what you want.Write a Python function that ...
SnippetA short piece of code for one job.one function
ReviewChecking something carefully and deciding if it is good.run it and read it
DesignA plan of how the solution will work, made before building.screens and steps
AlgorithmA list of steps that solves a problem.steps to join a waiting list
FlowchartA diagram of steps with arrows.start, check, book
LibraryCode other people wrote that you can use.pandas
FunctionA named piece of code that does one job.next_in_line()
InterfaceWhat the user sees and uses.a form

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

What a design pack holds

PartWhat it showsHillside example
Interface designThe screens the user will seeA "Join the waiting list" button and a list
Algorithm designThe steps for the key problemsA flowchart for moving the first person up when a booking is cancelled
Data designWhat is stored, and in what formA 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 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

An 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:

  1. The language and version.
  2. The job of one function.
  3. What goes in and what comes out.
  4. An example.
  5. 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

WeakStrong
Make a waiting listWrite 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 codeThis 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 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

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

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

Final check

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.