How to calculate the powers of 2 using anonymous (lambda) function in Python

1 Answer

0 votes
power = lambda x: 2 ** x

print("2 raised to power 3 =", power(3))
print("2 raised to power 4 =", power(4))

 
'''
run:
 
2 raised to power 3 = 8
2 raised to power 4 = 16
 
'''

 



answered May 30, 2017 by avibootz

Related questions

...