from functools import reduce
lst_simple = []
for i in range(18, 129):
for j in range(2, i // 2):
if i % j == 0:
break
else:
lst_simple.append(i)
print('Все простые числа', lst_simple)
lst_paired = []
lst_not_paired = []
for i in lst_simple:
try:
if lst_simple[lst_simple.index(i) + 1] == i + 2:
lst_paired.append(i)
lst_paired.append(lst_simple[lst_simple.index(i) + 1])
except IndexError:
pass
if i not in lst_paired:
lst_not_paired.append(i)
print('Все парные числа', lst_paired)
print('Все не парные числа', lst_not_paired)
print('Сумма всех парных', sum(lst_paired))
print('Сумма всех не парных', sum(lst_not_paired))
print('Произведение всех не парных чисел', reduce((lambda x, y: x * y), lst_not_paired))