Above average
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
This one builds on a lesson you haven't finished yet. Do that lesson first:
Python Basics · Functions →
Above average
Two loops, one after the other: the first works out the average, the second keeps the numbers above it.
This joins two patterns you have already used, the running total and the filter. Solving a problem in stages like this is how most longer programs are built.
Difficulty 3/5 · 200 coins + a small bonus on first completion today
Write above_average(nums) that returns a list of the numbers greater than the average of nums, in their original order. The list is never empty.
Click Run to see the output here.