BbJLeB

06. Odd Even Sum

May 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. # 06. Odd Even Sum
  2.  
  3. n = int(input())
  4. even_sum = 0
  5. odd_sum = 0
  6.  
  7. for position in range(1 , n+1):
  8.     current_num = int(input())
  9.     if position % 2 == 0:
  10.         even_sum += current_num
  11.     else:
  12.         odd_sum += current_num
  13.  
  14.  
  15. if even_sum == odd_sum:
  16.     print(f"Yes")
  17.     print(f"sum = {even_sum}")
  18. else:
  19.     diff = abs(even_sum - odd_sum)
  20.     print(f"No")
  21.     print(f"diff = {diff}")
Add Comment
Please, Sign In to add comment