Open lesson

Mission: the pattern of blank boxes

Command palette

This mission workspace keeps code and notes in this browser tab. Export them before closing it. Running code is practice, not an automatic grade for the mission.

Brief

Calculate four quality measures for a batch and show why denominators and subgroups change their meaning.

Imani prepares a meeting where Voss wants to call the missing operator_id mere chance. Mara lays eight practice cards on the table: T1, T2, and T3 without operators; T4 with one; C1, C2, and two C3 rows with operators. One C3 time is unreadable. Provide exact counts and an honest conclusion before the fictional meeting. No timer limits the exercise.

Your mission

  1. Give overall completeness and completeness by type as fractions and percentages.
  2. Give time validity and explain its denominator.
  3. Calculate rows with IDs appearing once and freshness at 12:00 UTC.
  4. Apply thresholds of 95%, 95%, 100%, and 60 minutes, then conclude without accusation.

How to check your work

  • Overall 5/8 = 62.5%; TRANSFER 1/4 = 25%; CHECK 4/4 = 100%.
  • Seven valid times among eight received rows: 87.5%.
  • Six rows with nonrepeated IDs of eight: 75%; freshness 10 min.
  • Completeness, validity, uniqueness fail; freshness passes; the cause remains open.

Course example

from collections import Counter
from datetime import datetime, timedelta, timezone

rows = [
    {"id": "T1", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:00:00Z"},
    {"id": "T2", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:10:00Z"},
    {"id": "T3", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:20:00Z"},
    {"id": "T4", "kind": "TRANSFER", "operator_id": "OP-4", "at": "2026-04-13T09:30:00Z"},
    {"id": "C1", "kind": "CHECK", "operator_id": "OP-1", "at": "2026-04-13T11:00:00Z"},
    {"id": "C2", "kind": "CHECK", "operator_id": "OP-2", "at": "2026-04-13T11:30:00Z"},
    {"id": "C3", "kind": "CHECK", "operator_id": "OP-3", "at": "2026-04-13T11:50:00Z"},
    {"id": "C3", "kind": "CHECK", "operator_id": "OP-3", "at": "bad-time"},
]
def present(row):
    value = row["operator_id"]
    return isinstance(value, str) and bool(value.strip())
counts = Counter(row["id"] for row in rows)
valid_times = []
for row in rows:
    try:
        instant = datetime.fromisoformat(row["at"].replace("Z", "+00:00"))
        if instant.utcoffset() == timedelta(0):
            valid_times.append(instant)
    except ValueError:
        pass
transfers = [row for row in rows if row["kind"] == "TRANSFER"]
checks = [row for row in rows if row["kind"] == "CHECK"]
as_of = datetime(2026, 4, 13, 12, 0, tzinfo=timezone.utc)
print(sum(1 for row in rows if present(row)), "/", len(rows))
print(sum(1 for row in transfers if present(row)), "/", len(transfers))
print(sum(1 for row in checks if present(row)), "/", len(checks))
print(len(valid_times), "/", len(rows))
print(sum(counts[row["id"]] == 1 for row in rows), "/", len(rows))
print(int((as_of - max(valid_times)).total_seconds() / 60), "minutes")

Code

Use Tab to leave the editor. Ctrl+Enter runs the source. The lines beginning with # are task reminders. Python ignores them. Write your code beneath them.

Python console

Loading laboratory…

Explore Python or SQL here; this is not an operating-system shell.

This is a disposable browser experiment. The code run here is not recorded as a completed mission.

Each command starts a fresh disposable worker: it runs a captured copy of your current source, then your command with the lesson fixtures. Changes are discarded afterward. Commands never save source or award XP. Ctrl+Enter executes the command.

Virtual workspace files

Source and declarative assets are readable here without JavaScript. Python input files are created at runtime; SQL setup initializes the disposable database.

source.py

Current editor source. Inspection shows your current edits.

# Give overall completeness and completeness by type as fractions and percentages.
# Give time validity and explain its denominator.
# Calculate rows with IDs appearing once and freshness at 12:00 UTC.
# Apply thresholds of 95%, 95%, 100%, and 60 minutes, then conclude without accusation.

exemple.py

Declarative lesson asset; this is not a file created in the Python filesystem.

from collections import Counter
from datetime import datetime, timedelta, timezone

rows = [
    {"id": "T1", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:00:00Z"},
    {"id": "T2", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:10:00Z"},
    {"id": "T3", "kind": "TRANSFER", "operator_id": None, "at": "2026-04-13T09:20:00Z"},
    {"id": "T4", "kind": "TRANSFER", "operator_id": "OP-4", "at": "2026-04-13T09:30:00Z"},
    {"id": "C1", "kind": "CHECK", "operator_id": "OP-1", "at": "2026-04-13T11:00:00Z"},
    {"id": "C2", "kind": "CHECK", "operator_id": "OP-2", "at": "2026-04-13T11:30:00Z"},
    {"id": "C3", "kind": "CHECK", "operator_id": "OP-3", "at": "2026-04-13T11:50:00Z"},
    {"id": "C3", "kind": "CHECK", "operator_id": "OP-3", "at": "bad-time"},
]
def present(row):
    value = row["operator_id"]
    return isinstance(value, str) and bool(value.strip())
counts = Counter(row["id"] for row in rows)
valid_times = []
for row in rows:
    try:
        instant = datetime.fromisoformat(row["at"].replace("Z", "+00:00"))
        if instant.utcoffset() == timedelta(0):
            valid_times.append(instant)
    except ValueError:
        pass
transfers = [row for row in rows if row["kind"] == "TRANSFER"]
checks = [row for row in rows if row["kind"] == "CHECK"]
as_of = datetime(2026, 4, 13, 12, 0, tzinfo=timezone.utc)
print(sum(1 for row in rows if present(row)), "/", len(rows))
print(sum(1 for row in transfers if present(row)), "/", len(transfers))
print(sum(1 for row in checks if present(row)), "/", len(checks))
print(len(valid_times), "/", len(rows))
print(sum(counts[row["id"]] == 1 for row in rows), "/", len(rows))
print(int((as_of - max(valid_times)).total_seconds() / 60), "minutes")