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

Free lesson

Policies, evidence and audits

After this lesson: I can test a control against its policy using a sample of evidence.

65 min lesson5 commandsJupyterLab data science lab: pandas, Matplotlib and scikit-learn in the browser

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 former employee still signs in

A designer left Lantern Print on a Tuesday. On Sunday her account was still active, and somebody used it.

The policy said accounts close within one day. Nobody had checked that the policy was followed.

By the end of this lesson

Note

I can test a control against its policy using a sample of evidence.

Key words

WordWhat it means
Policywhat leaders require, in plain words
Procedurethe steps staff follow to meet a policy
Evidencerecords that show what really happened
Samplesome items picked from all of them to test
Exceptionone item that broke the rule
Nonconformityan audit finding that a requirement was not met

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

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

From policy to evidence

LayerLantern Print example
PolicyAccess ends when somebody leaves
StandardAccounts are disabled within one day of leaving
ProcedureHR emails IT on the last day; IT disables the account
EvidenceHR's leaving dates and the system's disable dates

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

An audit compares evidence with the rule

An audit asks whether a control works, not whether it is written down. The auditor takes the rule, gathers evidence and looks for exceptions.

Checking every record by hand takes too long, so auditors test a sample. An internal audit is done by the firm itself; an external one by an outside body.

Try it: how late was one account?

Code: python
import datetime

left = datetime.date(2026, 7, 21)
disabled = datetime.date(2026, 7, 27)
allowed = 1
late = max(0, (disabled - left).days - allowed)
print("days late:", late)
# Change disabled to the day after leaving and run again.

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

Check

Have a go

Check

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

Audit a year of leavers

leavers.py makes a year of 60 leavers from a fixed seed, each with a leaving day and a disable day. audit.py picks a sample of 15, finds the exceptions and gives a result.

Our rule for the result: none is conforms, up to 10 per cent is minor, above that is major.

Write the leavers

Command
docker exec jupyter sh -c "mkdir -p steps && printf '%s\n' 'import datetime' 'import random' '' 'rng = random.Random(137)' 'start = datetime.date(2026, 1, 5)' 'leavers = []' 'for n in range(1, 61):' '    left = start + datetime.timedelta(days=rng.randint(0, 300))' '    delay = rng.choice([0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 6])' '    leavers.append((f\"P{n:03}\", left.isoformat(), (left + datetime.timedelta(days=delay)).isoformat()))' > steps/leavers.py"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the audit, part 1

Command
docker exec jupyter sh -c "mkdir -p steps && printf '%s\n' 'import datetime' 'import random' 'import sys' 'from leavers import leavers' '' 'ALLOWED = 1' '' '' 'def days_late(left, disabled):' '    gap = datetime.date.fromisoformat(disabled) - datetime.date.fromisoformat(left)' '    return max(0, gap.days - ALLOWED)' '' '' 'def rating(found, tested):' '    if found == 0:' '        return \"conforms\"' '    return \"minor nonconformity\" if found / tested <= 0.1 else \"major nonconformity\"' '' '' 'tested = leavers' 'if \"all\" not in sys.argv:' '    tested = sorted(random.Random(5).sample(leavers, 15))' 'print(\"leavers in the year:\", len(leavers), \" tested:\", len(tested))' 'late = [(p, left, off, days_late(left, off)) for p, left, off in tested if days_late(left, off)]' 'for p, left, off, days in late:' '    print(f\"  {p} left {left}, disabled {off}, days late: {days}\")' > steps/audit.py"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Write the audit, part 2

Command
docker exec jupyter sh -c "printf '%s\n' 'print(\"exceptions:\", len(late), \"of\", len(tested), \" result:\", rating(len(late), len(tested)))' >> steps/audit.py"

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Test a sample of 15

Command
docker exec jupyter python3 steps/audit.py

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

Check

Have a go

Check

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

With data, test the whole population

A sample is a guess about the whole. When the evidence is data, a short program can test every record. Run the audit with all.

The sample found 2 exceptions. The whole year shows how many the sample missed.

Test all 60 leavers

Command
docker exec jupyter python3 steps/audit.py all

Shown here, not run. Press Start lab to type it into your own lab’s terminal.

A common mistake

Warning

Many people think a written policy means the control works. The policy here was clear, and 12 of 60 accounts still closed late. Only evidence shows what happened, which is why an audit reads records rather than documents.

Assignment: audit the leavers

Dates are strings such as "2026-03-02".

days_late(left, disabled, allowed) returns the days beyond those allowed, never below 0. exceptions(rows, allowed) takes (id, left, disabled) rows and returns the late ids, sorted. rating(found, tested) returns "conforms", "minor nonconformity" (10 per cent or less) or "major nonconformity".

Code: python
import datetime


def days_late(left, disabled, allowed):
    # Dates are "YYYY-MM-DD". Days from leaving to disabling, minus the days allowed, never below 0.
    return 0


def exceptions(rows, allowed):
    # rows is a list of (id, left, disabled). The ids that were late, sorted.
    return []


def rating(found, tested):
    # "conforms" when none were found, "minor nonconformity" when found / tested is 0.1 or less,
    # "major nonconformity" otherwise.
    return ""

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

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

Teaching a class? Set this module for your students with a teacher guide, marked assignments and a lab for every student.