Average of a list · 列表的平均数
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
Average of a list
Return the mean of a list: the total divided by how many numbers there are.
len(nums) tells you how many items the list has. Dividing with / always gives a decimal, so the average of 1 and 2 is 1.5.
中文
列表的平均数
返回列表的平均数:总和除以数的个数。
len(nums) 告诉你列表里有多少个元素。用 / 做除法总会得到小数,所以 1 和 2 的平均数是 1.5。
Write average(nums) that returns · 返回值 the mean: the total divided by how many numbers there are. The list is never empty. · 编写 average(nums),返回平均数:总和除以数的个数。列表不会是空的。
Click Run to see the output here. · 点击“运行”查看此处输出。