Above average · 高于平均数
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
This one builds on a lesson you haven't finished yet. Do that lesson first: · 此任务基于您尚未完成的课程。请先完成以下课程:
Python Basics · Python 基础 · Functions · 函数 →
English
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.
中文
高于平均数
两个循环,一个接一个:第一个算出平均数,第二个留下比它大的数。
这把你用过的两种方法结合了起来:累计求和与筛选。像这样分步骤解决问题,是大多数较长程序的写法。
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. · 编写 above_average(nums),按原来的顺序返回所有大于 nums 平均数的数。列表不会是空的。
Click Run to see the output here. · 点击“运行”查看此处输出。