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

Preview

AESP task 3: Define every step of a data process

This is the first page of the lesson. Read it and have a go at the activities. The rest is in the full lesson.

55 minutes

"Then it just sort of works"

A design says: "The file is loaded, and then the points are worked out." A builder asks: loaded how? From where? What if a row is bad? What exactly goes into the points step?

A good design leaves no gap for a guess.

Key words

WordWhat it means
Processa series of steps that turns an input into an output
Inputwhat goes into a step
Outputwhat a step gives out
Data assurancethe checks that make data accurate and reliable
Flowcharta diagram of steps joined by arrows
Dependencywhen one step needs the result of another

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

By the end of this lesson

Note

I can define each step of a data process with its input, action, output and check, so that every step uses the one before.

Starter

Have a go

Starter

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

Your answers are marked here and are not kept. A college account keeps every student’s marks.

This is practice

Important

The real task comes from the exam board. This lesson uses an invented organisation and its own made-up data. Your teacher tells you how the real tasks are set and what you may bring.

Worked example: each step defined

StepInputActionOutputData assurance
1 ReadThe sales fileRead every line into a listA list of raw rowsCount the lines read
2 CheckThe raw rowsTest type, range and dateGood rows and a problem listEvery row is in one list or the other
3 CleanThe good rowsTrim spaces, fix capitalsClean rowsRe-run the checks
4 LoadThe clean rowsInsert into the tablesRows in the tablesRows loaded equals clean rows
5 PointsThe loaded salesOne point for each whole poundPoints for each customerTotal points equals total pounds
6 ReportThe pointsSort and printA one page reportCheck one customer by hand

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

Run it: each step uses the last

Code: python
raw = [["Maya", "12"], ["Ben", "oops"], ["Maya", "8"], ["Ben", "5"]]

problems = []
good = []
for row in raw:
    if row[1].isdigit():
        good.append([row[0], int(row[1])])
    else:
        problems.append(row)

points = {}
for row in good:
    if row[0] in points:
        points[row[0]] = points[row[0]] + row[1]
    else:
        points[row[0]] = row[1]

print("read", len(raw), "good", len(good), "problems", len(problems))
print(points)

Rules for a good step

Each step has one job. Its input is the output of an earlier step, so you can follow the data from the start to the end.

Say what happens to a bad value. The problem list is an output too: nothing is thrown away without a record.

End every step with a check that you could run.

The lesson goes on

6 more parts of this lesson are in the full curriculum, with the tasks, the final check and the labs. A college account gives your students all of it.