Where Are the Fences?

Data with PythonEasy+10 XP+10

Where Are the Fences?

A bus company logs how many minutes late each bus arrives. Before flagging anything, the manager wants to see where the 1.5 × IQR fences sit.

Task: write fences(minutes), where minutes is a list of numbers.

  • Q1 and Q3 come from pandas quantile(0.25) and quantile(0.75).
  • IQR = Q3 − Q1.
  • low fence = Q1 − 1.5 × IQR, high fence = Q3 + 1.5 × IQR.
  • Return [low fence, high fence], each rounded to 2 decimal places.

There is always at least one value, and none is missing.

Examples

minutes = [12, 14, 15, 15, 16, 18, 19, 21, 95]
returns [9.0, 25.0]
minutes = [0, 2, 3, 5, 8]
returns [-2.5, 9.5]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run