题解 | #记负均正#
记负均正
https://www.nowcoder.com/practice/6abde6ffcc354ea1a8333836bd6876b8?tpId=37&tqId=21320&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
import sys #from numpy import average #for line in sys.stdin: # a = line.split() # print(int(a[0]) + int(a[1])) n=input() number = input().split() #定义一个球平均数的函数 def MyAverage(L): sum =0 length=len(L) if length==0: average=float(0) return average for x in L: sum+=x #平均数的结果用('%.1f')%float(sum/length)取一位小数 average=('%.1f')%float(sum/length) return average #将正数和负数放到俩个列表,将列表中的元素转化为In型 def count(number): func = lambda x: int(x) number = map(func, number) L1=[] L2=[] for x in number: if x>0: L1.append(x) elif x<0: L2.append(x) else: pass average=MyAverage(L1) print(len(L2),average) return 0 count(number)