Editor

Which Groups Are Below the Goal?

Intermediate · Write the code · from Effects of Computing: Benefits, Harms and the Digital Divide

From the lesson: Effects of Computing: Benefits, Harms and the Digital Divide

People create computing innovations to do one job well, and those innovations then change how everyone works, plays and learns in ways their creators never fully planned. Think about how everyday tasks have changed. Homework goes through an online portal instead of a paper stack on the teacher's desk.

Read the lesson

A state wants every group to reach a target rate of internet access. Write groups_below_goal(rates, goal) that returns a list of the names of the groups whose rate is below goal, sorted from the lowest rate to the highest. A group exactly at the goal has met it.

groups_below_goal({"urban": 92, "suburban": 89, "rural": 72}, 90)  ->  ["rural", "suburban"]
def groups_below_goal(rates, goal):
# Return the names below the goal, lowest rate first
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(groups_below_goal({"urban": 92, "suburban": 89, "rural": 72}, 90))['rural', 'suburban']
print(groups_below_goal({"urban": 92, "rural": 72}, 50))[]

More Effects of Computing exercises

All Python exercises · 50 practice problems