You will write three small functions that turn a sample into numbers about the population: the sample percentage, an estimate of a total, and the spread of several statistics.
The idea. A sample is stored as a list of 1s and 0s: 1 for a student who has the property, 0 for one who does not. The sample percentage is . If a fair sample is used for a population of , the estimate of the total is .
Your tasks.
share(sample). Return the percentage of 1s in the list.estimate_total(sample, N). Return the estimated number in a population of N.spread(statistics). Return the largest value minus the smallest value.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…