You will write four small functions that find the mean, the median and the mode of a list, and the mean of grouped data. The checker tests them on lists with an odd and an even number of values, and on a frequency table.
The idea. The mean is the total divided by the count. The median is the middle value of the sorted list, or the mean of the two middle values. The mode is the value that occurs most often. For grouped data, each class is represented by its class mark, and each class mark is counted as many times as the class frequency.
Your tasks.
mean_of(data).median_of(data). Sort the list first, and look at whether the length is odd or even.mode_of(data). If two values tie, return the smaller one.grouped_mean(marks, freqs), where marks are the class marks.Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…