Advertisement
aneliabogeva

Odd / Even Position

May 20th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import sys
  2. n = int(input())
  3.  
  4. min_num_odd = sys.maxsize
  5. max_num_odd = -sys.maxsize - 1
  6. min_num_even = sys.maxsize
  7. max_num_even = -sys.maxsize - 1
  8.  
  9. odd_summ = 0
  10. even_sum = 0
  11.  
  12. for i in range(1, n+1):
  13. current_num = float(input())
  14. if i % 2 == 0:
  15. if current_num > max_num_even:
  16. max_num_even = current_num
  17. if current_num < min_num_even:
  18. min_num_even = current_num
  19. even_sum += current_num
  20. else:
  21. if current_num > max_num_odd:
  22. max_num_odd = current_num
  23. if current_num < min_num_odd:
  24. min_num_odd = current_num
  25. odd_summ += current_num
  26. if odd_summ != 0:
  27. print(f"OddSum={odd_summ:.2f},")
  28. print(f"OddMin={min_num_odd:.2f},")
  29. print(f"OddMax={max_num_odd:.2f},")
  30. else:
  31. print(f"OddSum={(odd_summ):.2f},")
  32. print(f"OddMin=No,")
  33. print(f"OddMax=No,")
  34. if even_sum != 0:
  35. print(f"EvenSum={even_sum:.2f},")
  36. print(f"EvenMin={min_num_even:.2f},")
  37. print(f"EvenMax={max_num_even:.2f}")
  38. else:
  39. print(f"EvenSum={(even_sum):.2f},")
  40. print(f"EvenMin=No,")
  41. print(f"EvenMax=No")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement