Advertisement
go6odn28

For-Loop - More Exercises_8

Sep 30th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | Software | 0 0
  1. n = int(input())
  2. number1 = int(input())
  3. number2 = int(input())
  4. sum1 = number1 + number2
  5. max_diff = 0
  6.  
  7. for i in range(n - 1):
  8.     number1 = int(input())
  9.     number2 = int(input())
  10.     sum2 = number1 + number2
  11.  
  12.     diff = abs(sum2 - sum1)
  13.     if diff > max_diff:
  14.         max_diff = diff
  15.  
  16.     sum1 = sum2
  17.  
  18. if max_diff == 0:
  19.     print(f'Yes, value={sum1}')
  20. else:
  21.     print(f'No, maxdiff={max_diff}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement