V
V
vityaba32018-05-06 16:24:53
Python
vityaba3, 2018-05-06 16:24:53

Is there a function to find the average value of an array of boolean variables in Python3?

Is there a function in python or some library that finds the average value of an array with boolean variables?
Those. Returning True If more than half of the variables in the array are (not) strictly True?
Or

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

The fact is that if it is standard, it will work faster (probably)
(Python loops do not differ in speed)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Max Payne, 2018-05-06
@vityaba3

f = lambda data: data.count(True) >= len(data)/2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question