Untitled
Anonymous
python
02/28/2022 3:15 PM
876 B
21
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...