Quiz 2
Registry Synced

Synthetic 7 · Delivery Summary

167 words
1 min read
2026-08-02

Delivery Summary

Each delivery is (origin, destination, delay_minutes). Write delivery_summary(records) returning a dictionary with: on_time_rate (delay below 10 minutes, percentage rounded to two decimals), worst_route (largest average delay; first appearing route wins a tie), and busiest_hub (most appearances as origin or destination; alphabetical tie-break). Empty input returns zero/None values.

Template Code

python
def delivery_summary(records):
    pass

Public Tests

is_equal(delivery_summary([]), {"on_time_rate": 0.0, "worst_route": None, "busiest_hub": None}) is_equal(delivery_summary([("A", "B", 5), ("A", "C", 20), ("A", "B", 15)]), {"on_time_rate": 33.33, "worst_route": ("A", "C"), "busiest_hub": "A"})
MCQ
3 Unit Assessment

Reference-only archive item

The completed export preserved the prompt as an image but not a reusable answer key. The reconstruction below is for study, not scoring.

Study reconstruction
def delivery_summary(records):
    if not records:
        return {"on_time_rate": 0.0, "worst_route": None, "busiest_hub": None}
    route_delays = {}
    hub_counts = {}
    on_time = 0
    for origin, destination, delay in records:
        on_time += delay < 10
        route = (origin, destination)
        route_delays.setdefault(route, []).append(delay)
        hub_counts[origin] = hub_counts.get(origin, 0) + 1
        hub_counts[destination] = hub_counts.get(destination, 0) + 1
    worst_route = max(route_delays, key=lambda route: sum(route_delays[route]) / len(route_delays[route]))
    busiest_hub = min(hub_counts, key=lambda hub: (-hub_counts[hub], hub))
    return {
        "on_time_rate": round(100 * on_time / len(records), 2),
        "worst_route": worst_route,
        "busiest_hub": busiest_hub,
    }
Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.