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

Preview

DA 3.4, 3.5: Applying methods and showing results

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

Two analysts, one answer

Two analysts find the busiest day in a made-up cafe's sales. Both get Saturday. One finishes in a blink. The other makes the computer work 12 times harder.

Then each writes the result for the owner. One gives six decimal places. The owner wanted one line. Good analysis needs the right method and the right amount of detail.

Key words

WordWhat it meansExample
AlgorithmA set of steps for doing a job.Find the highest value
EfficientGets the answer with few steps and little waste.One pass over the data
Level of detailHow much information a result shows.A weekly total, not every sale
AccuracyHow close a figure is to the true value, and how many places it shows.3.97 or about 4
RepresentationThe form a result is shown in.A table, a line chart or one sentence
RequirementWhat the finished analysis must be able to show.Show if sales rise each week
DatabaseA store of organised data, kept in tables.The sales tables
LoopCode that repeats the same steps.A loop over every value
AudienceThe people who will read the result.The cafe owner

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

By the end of this lesson

Note

I can apply a method efficiently, show the result at the right level of detail and accuracy, and review it against the requirement.

Starter: last lessons

Have a go

Starter: last lessons

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.

Apply a method efficiently

An algorithm is a set of steps. Two algorithms can give the same answer in a very different number of steps.

Find the highest value. You can compare every value with every other, or look at each value once and remember the highest so far. The second is efficient. With a million rows, the difference is hours.

Try it: count the steps

Code: python
values = [40, 42, 45, 50, 70, 90, 30, 48, 50, 53, 58, 78]

slow_steps = 0
slow_answer = 0
for a in values:
    is_highest = True
    for b in values:
        slow_steps = slow_steps + 1
        if b > a:
            is_highest = False
    if is_highest:
        slow_answer = a

fast_steps = 0
fast_answer = values[0]
for v in values:
    fast_steps = fast_steps + 1
    if v > fast_answer:
        fast_answer = v

print("Compare every pair:", slow_answer, "in", slow_steps, "steps")
print("One pass:", fast_answer, "in", fast_steps, "steps")

Habits that save work

  1. Use the simplest method that meets the requirement.
  2. Let the database do the adding up. A group by is quicker than your own loop.
  3. Test on a small sample first.
  4. Do not repeat work you already did. Keep the result and reuse it.

Show it at the right level

Choose the level of detail and the accuracy to suit the audience and the requirement.

The owner needs a headline, such as "Sales rise about 8 a week". A data team may need the slope to two places and a table by day. Too much detail hides the answer. Too little cannot be checked.

Worked example: one result, three audiences

AudienceLevel of detailAccuracyForm
Cafe ownerOne headlineWhole numbers: about 8 a weekA sentence and one line chart
Shop managerTotals by weekOne decimal placeA small table
Data teamEvery day, with the methodTwo decimal placesTable, chart and a note on the method

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

The lesson goes on

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