You are viewing a single comment's thread. Return to all comments →
enumerate is slightly faster than for
def plusMinus(arr): positives = 0 zeros = 0 negatives = 0 size = len(arr)
for number arr: if number > 0 : positives += 1 elif number == 0 : zeros += 1 else: negatives += 1 print(f'{positives/size:.6f}') print(f'{negatives/size:.6f}') print(f'{zeros/size:.6f}')
if name == 'main': n = int(input().strip())
arr = list(map(int, input().rstrip().split())) plusMinus(arr)
Seems like cookies are disabled on this browser, please enable them to open this website
Plus Minus
You are viewing a single comment's thread. Return to all comments →
enumerate is slightly faster than for
def plusMinus(arr): positives = 0 zeros = 0 negatives = 0 size = len(arr)
if name == 'main': n = int(input().strip())