Advertisement
Nenogzar

Untitled

Oct 14th, 2023
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. numbers = int(input())
  2.  
  3. evan_sum = 0
  4. evan_max = float('-inf')
  5. evan_min = float('inf')
  6.  
  7. odd_sum = 0
  8. odd_max = float('-inf')
  9. odd_min = float('inf')
  10.  
  11. for num in range(1, numbers + 1):
  12.     check_number = float(input())
  13.  
  14.     if num % 2 == 0:  # Even position
  15.         evan_sum += check_number
  16.         evan_max = max(evan_max, check_number)
  17.         evan_min = min(evan_min, check_number)
  18.     else:  # Odd position
  19.         odd_sum += check_number
  20.         odd_max = max(odd_max, check_number)
  21.         odd_min = min(odd_min, check_number)
  22.  
  23.  
  24. print(f"OddSum={odd_sum:.2f},")
  25. if odd_min == float('inf'):
  26.     print("OddMin=No,")
  27. else:
  28.     print(f"OddMin={odd_min:.2f},")
  29. if odd_max == float('-inf'):
  30.     print("OddMax=No,")
  31. else:
  32.     print(f"OddMax={odd_max:.2f},")
  33.  
  34. print(f"EvenSum={evan_sum:.2f},")
  35. if evan_min == float('inf'):
  36.     print("EvenMin=No,")
  37. else:
  38.     print(f"EvenMin={evan_min:.2f},")
  39. if evan_max == float('-inf'):
  40.     print("EvenMax=No")
  41. else:
  42.     print(f"EvenMax={evan_max:.2f}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement