Untitled
unknown
python
4 years ago
656 B
10
Indexable
def calculateNegativeCount(array):
count = 0
for element in array:
if element < 0:
count += 1
return count
# Ноль считается положительным числом
def calculatePositiveCount(array):
count = 0
for element in array:
if element >= 0:
count += 1
return count
def calculateFormula(negativeCount, positiveCount):
result = (negativeCount + positiveCount) / float(negativeCount)
return result
B = [2, 5, -6, 8, -3, 7, 12, -45, 106, 4]
Ko = calculateNegativeCount(B)
Kp = calculatePositiveCount(B)
K = calculateFormula(Ko, Kp)
print(K)
Editor is loading...