Is there a function, nahodtsya average value of an array of Boolean variables in Python3?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
12 views
Whether in python or some library function which finds the average value of an array with Boolean variables?
Ie Returns True If array is (not)strictly more than half of the variables are True?
Or

def binmean(data): count = 0 for i in range(len(data)): inc(count); if data[i] return True if co >= len(data)/2 else False


The fact is that if it is standard-to work will be faster (probably)
(Loops in Python do not differ in speed)
by | 12 views

1 Answer

0 like 0 dislike
f = lambda data: data.count(True) >= len(data)/2
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
4 answers
0 like 0 dislike
4 answers
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users