# Desktop Python teaching example. Numerical inputs are illustrative.
from statistics import mean
trials = [
    {"arrived": True, "error_m": 0.04, "reason": "arrived"},
    {"arrived": True, "error_m": 0.08, "reason": "arrived"},
    {"arrived": False, "error_m": None, "reason": "hazard"},
]
errors = [t["error_m"] for t in trials if t["arrived"]]
print("attempts", len(trials), "arrivals", len(errors))
print("arrival_fraction", len(errors) / len(trials))
print("mean_error_given_arrival_m", mean(errors) if errors else None)
