sum of powers:
you are given a list of integers L of size N.write a program to compute the value of SUM
SUM=x1pow1+x2pow2+x3pow3+---+xNpowN
where xi concatenated with powi is the i th element of the list L
and powj is a single digit number
i/p: the input contains space separated N integers
the o/p should be a single integer denoting SUM
L=[25]
o/p:x1=2 , pow1=5
SUM=2^5=32
i/p: 132 301
o/p:199
def term(n):
p = n % 10
x = n // 10
return x**p
def sum(L):
s = 0
for n in L:
s += term(n)
return s
def main():
line = input()
L = [int(s) for s in line.split()]
print(sum(L))
if __name__ == '__main__':
main()
Comments
Leave a comment