-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
110 lines (84 loc) · 2.13 KB
/
main.py
File metadata and controls
110 lines (84 loc) · 2.13 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import random
print('\t' * 3, '*'* 10, 'Task 1', 10 * '*')
NUMS_SIZE = 10
numbers = []
negativ = 0
parni = 0
neparni = 0
kratnye3 = 1
dobutok_min_max = 1
poz1 =0
poz2 =0
random.randint(-5, 5)
for i in range(NUMS_SIZE):
numbers.append(random.randint(-5, 5))
if numbers[i] < 0:
negativ += numbers[i]
if numbers[i] % 2 == 0:
# print(numbers[i], end=' ')
parni += numbers[i]
elif numbers[i] % 2 == 1:
# print(numbers[i], end=' ')
neparni += numbers[i]
print(f'List created: {numbers}')
print()
print(f'The sum of negative numbers is: {negativ}')
print(f'The sum of even numbers is: {parni}')
print(f'The sum of odd numbers is: {neparni}')
for i in numbers:
if i==0:
continue
elif i%3 ==0:
# print(i, end=' ')
kratnye3 *=i
print(f'The product of numbers that are multiples of "3" is equal to: {kratnye3}')
min_numb = numbers.index(min(numbers))
max_numb = numbers.index(max(numbers))
for i in numbers[min_numb + 1:max_numb]:
if i ==0:
continue
else:
dobutok_min_max *=i
print(f'The product of the elements between min and max is: {dobutok_min_max}')
for i in numbers:
if i >0:
poz1 +=i
# print(i, end=' ')
print()
for i in reversed(numbers):
if i > 0:
poz2 +=i
# print(i, end=' ')
if poz1 == poz2:
print(f'The sum of the elements that are between the first and last positive element: {poz1}')
else:
print('Error')
print()
print()
print('\t' * 3, '*'* 10, 'Task 2', 10 * '*')
NUMS_SIZE = 10
parni = []
neparni =[]
negotiv = []
pozitiv = []
numbers = []
for i in range(NUMS_SIZE):
numbers.append(random.randint(-5, 5))
new = numbers.copy()
print()
for i in new:
if i ==0:
continue
elif i%2 == 0:
parni.append(i)
elif i%2 == 1:
neparni.append(i)
if new[i] < 0:
negotiv.append(new[i])
elif new[i] > 0:
pozitiv.append(new[i])
print(f'New list created: {new}')
print(f'List with even numbers: {parni}')
print(f'List with odd numbers: {neparni}')
print(f'List with negative numbers: {negotiv}')
print(f'List with positive numbers: {pozitiv}')