0 of 6 problems solved • 0%

Exercise prompt

Find Typical Pages

The median is the middle of the sorted readings. With an even number of entries it is the average of the middle two. Python's statistics module includes this calculation.

Example

Two waiting-time samples show how an outlier affects the mean and median differently.

from statistics import mean, median waits = [2, 3, 25] print(mean(waits)) # 10 print(median(waits)) # 3

The median picks the middle after sorting. Decide separately what your function should do when there are no observations.

Your task

Complete typical_pages(pages). Use the median for a nonempty list of numbers and return None for an empty list. Preserve the input.

typical_pages([8, 1, 4]) # 4 typical_pages([3, 8]) # 5.5