Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/bin/python3
  2.  
  3. import os
  4. import sys
  5.  
  6. #
  7. # Complete the plusMinus function below.
  8. #
  9. def plusMinus(arr):
  10. #
  11. # Write your code here.
  12. #
  13. n = len(arr)
  14. count_z = 0
  15. count_p = 0
  16. count_n = 0
  17. for x in range(0,n):
  18. if arr[x] == 0:
  19. count_z += 1
  20. elif arr[x] > 0:
  21. count_p += 1
  22. else:
  23. count_n += 1
  24. per_z = "{:.6f}".format(count_z/n)
  25. per_p = "{:.6f}".format(count_p/n)
  26. per_n = "{:.6f}".format(count_n/n)
  27. print (per_p)
  28. print (per_n)
  29. print (per_z)
  30.  
  31. if __name__ == '__main__':
  32. n = int(input())
  33.  
  34. arr = list(map(int, input().rstrip().split()))
  35.  
  36. plusMinus(arr)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement