以下代码,要求通过调用函数mean计算出列表元素的平均值,并输出。请完善代码。
def mean(numlist):
s = 0.0
for num in numlist:
s = s + num
return s/len(numlist)
ls = [11,43,23,37,61,29]
print("平均值为:",【 】)
def mean(numlist):
s = 0.0
for num in numlist:
s = s + num
return s/len(numlist)
ls = [11,43,23,37,61,29]
print("平均值为:",【 】)
举一反三
- 下面叙述正确的是( )。知识点:集合 A: 以下代码的输出结果为8。s = {8,16,9,10,5}ls = list(s)ls.sort()print(ls[1]) B: 以下代码的输出结果为16。s = {8,16,9,10,5}print(s[1]) C: 以下代码的输出结果为5。s = {8,16,5,10,5}print(len(s)) D: 以下代码的输出结果为{5,8,9,10,16}。s = {8,16,9,10,5}s.sort()print(s)
- 以下程序段的输出结果是 。 int main(void) { int num = 0,s = 0; while(num <= 2){ num++; s += num; } printf("%d\n",s); return 0; }
- 下面代码的输出结果是() deffunc(a,b): a *= b return a s = func(5,2) print(s)
- 下面代码的输出结果是 s =["seashell","gold","pink","brown","purple","tomato"] print(len(s),min(s),max(s))
- 以下代码的输出结果是。 for s in "testatest": if s=="a": continue print(s, end=')