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

Free lesson

OS 1.1 (3 of 8): Design the product and check AI code

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.

50 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

Plan the house before you build it

Nobody builds a house by laying bricks and hoping. They draw plans first.

Software needs plans too. You draw the screens. You plan the steps. You plan the data.

Today you also meet a new helper: an AI tool that can write code. It is fast. But you must check every line.

Key words

WordWhat it meansExample
InterfaceThe part of the software that a user sees and touches.screens and buttons
WireframeA simple drawing of a screen, with no colour or pictures.boxes for the logo and the menu
AlgorithmA list of steps that solves a problem.how to work out the order total
FlowchartA picture of steps joined by arrows.start, add up the food, show the bill
FunctionA named block of code that does one job.delivery_fee
LicencePermission, with rules, to use something that somebody else made.free to copy, but you must say who made it
Data requirementWhat facts the software must store, and what kind each one is.name: text; price: a number
Generative AIA tool that makes new text or code from a request you type.a chat tool that writes a function
PromptThe request you type to a generative AI.Write a function for a delivery fee.
ReviewTo read and check work made by somebody else or by a tool.check the code against the list of requirements
RequirementSomething the software must do or be.Delivery is free at 20 pounds or more.

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

Quick check: design words

Have a go

Quick check: design words

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

Three things to design

DesignWhat you makePizza app example
InterfaceWireframes of each screenThe order screen: pizza list, size buttons, total, Pay button
AlgorithmsFlowcharts or step listsSteps to add up the basket and the delivery fee
DataA table of the facts to storeCustomer name, phone number, pizza, size, price

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

Data requirements for an order

FieldKind of dataRule
customer_nameTextCannot be empty
phoneTextText, because we never do sums with phone numbers
quantityWhole number1 to 10
priceNumber with decimalsNever below 0
paidTrue or FalseFalse until payment works

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

Your turn: a wireframe

Make a wireframe of a sign-in screen for the school app. Use only boxes and text, no colours. It needs a title, an email box, a password box, a Sign in button and a link that says "Forgot password?". Change the HTML on the left and look at the preview. Keep it simple.

Code: web
<h1>School app</h1>
<!-- Add the email box, the password box, the button and the link here -->

Make a free account to save your work, or press Start lab to work through the whole lesson.

An algorithm for the delivery fee

flowchart TD
  a([Start]) --> b[Add up the food]
  b --> c{Food total is 20 or more?}
  c -->|yes| d[Fee is 0]
  c -->|no| e[Fee is 3]
  d --> f[Show the bill]
  e --> f

AI code can look right and be wrong

A generative AI can write a section of code in seconds. You type a prompt. It gives code back.

The code looks neat and correct, but it can be wrong. The AI does not know your requirements unless you tell it. You check every line you use.

Run the AI code: it looks fine

Code: python
def delivery_fee(food_total):
    if food_total > 20:
        return 0
    return 3

print(delivery_fee(10))
print(delivery_fee(30))
print(delivery_fee(20))

# Requirement: free delivery at 20 or more.
# Look at the last line of output. Is it right?

Make a free account to save your work and track your progress.

How to review AI code

Important

  1. Write the requirements first. 2. Ask the AI for one small function. 3. Read every line. 4. Test the limits: the smallest, the biggest and the exact limit. 5. Fix it, or ask again with a better prompt.

Your turn: fix the AI code

An AI tool wrote the three functions in the starter. Each one breaks a requirement. Read the comment above each function, then fix the code. The hidden tests check the exact limits. Press Run Tests when you are ready.

Code: python
# An AI tool wrote these three functions for the pizza app.
# They run, but each one breaks a requirement. Fix them.

def delivery_fee(food_total):
    # Requirement: delivery costs 3. It is free when the food total is 20 or more.
    if food_total > 20:
        return 0
    return 3


def valid_quantity(quantity):
    # Requirement: a customer may order from 1 to 10 of the same pizza.
    return 1 < quantity < 10


def display_name(name):
    # Requirement: show the name with only the first letter in capitals.
    # For "aisha" give back "Aisha".
    return name.upper()

Make a free account to save your work, or press Start lab to work through the whole lesson.

Good habit or bad habit?

Have a go

Good habit or bad habit?

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

Keep private data out of prompts

Warning

Never type a real customer name, address or password into an AI tool. Use made-up data. Check your college rules too, and the licence of any code you copy.

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.