-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIV.03-odd-even-sum.py
48 lines (36 loc) · 938 Bytes
/
IV.03-odd-even-sum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import sys
loop = int(input())
odd_sum = 0
odd_min = sys.maxsize
odd_max = -sys.maxsize
even_sum = 0
even_min = sys.maxsize
even_max = -sys.maxsize
for l in range(1, loop + 1):
num = float(input())
if l % 2 == 0:
even_sum += num
if num > even_max:
even_max = num
if num < even_min:
even_min = num
else:
odd_sum += num
if num > odd_max:
odd_max = num
if num < odd_min:
odd_min = num
print(f"OddSum={odd_sum:.2f},")
if odd_min == sys.maxsize or odd_max == -sys.maxsize:
print(f"OddMin=No,")
print(f"OddMax=No,")
else:
print(f"OddMin={odd_min:.2f},")
print(f"OddMax={odd_max:.2f},")
print(f"EvenSum={even_sum:.2f},")
if even_min == sys.maxsize or even_max == -sys.maxsize:
print(f"EvenMin=No,")
print(f"EvenMax=No")
else:
print(f"EvenMin={even_min:.2f},")
print(f"EvenMax={even_max:.2f}")