a=str(input())
if int(a[3])%2==0: print(int(a[0])+int(a[1]) +int(a[2])+int(a[3]))
else: print(int(a[0])*int(a[1]) *int(a[2])*int(a[3]))
Объяснение:
Python 3.7.2
import functools
num = input()
print(f'{sum([int(i) for i in num])}' if (int(num) % 2 == 0) \
else f'{functools.reduce(lambda x, y: x * y, [int(i) for i in num])}')
a=str(input())
if int(a[3])%2==0: print(int(a[0])+int(a[1]) +int(a[2])+int(a[3]))
else: print(int(a[0])*int(a[1]) *int(a[2])*int(a[3]))
Объяснение:
Python 3.7.2
import functools
num = input()
print(f'{sum([int(i) for i in num])}' if (int(num) % 2 == 0) \
else f'{functools.reduce(lambda x, y: x * y, [int(i) for i in num])}')