Editor

The Crowd's Estimate

Intermediate · Write the code · from Computing Bias and Crowdsourcing: Unfair Data, Shared Effort

From the lesson: Computing Bias and Crowdsourcing: Unfair Data, Shared Effort

A program can treat people unfairly even when nobody meant it to, because people write its rules and choose the data it learns from. Computing innovations can reflect existing human biases in two main ways. Bias can be written into the algorithm, through the rules a programmer chooses.

Read the lesson

Write crowd_estimate(guesses) that returns the median of a non-empty list of guesses. Sort the guesses; the median is the middle value. When there is an even number of guesses, the median is the average of the two middle values.

crowd_estimate([40, 52, 48])        ->  48
crowd_estimate([40, 52, 48, 1000])  ->  50.0
def crowd_estimate(guesses):
ordered = sorted(guesses)
# Return the middle value (or the average of the two middle values)
pass

What Check runs

Your code runs first, then each of these lines, and 2 more that stay hidden. The output must match exactly.

RunsExpected output
print(crowd_estimate([40, 52, 48]))48
print(crowd_estimate([40, 52, 48, 1000]))50.0

More Computing Bias exercises

All Python exercises · 50 practice problems