Programming Code Center(PCC)
[PYTHON]

(PCC)::[How-to-write-Python-Program-To-Display-Powers-of-2-Using-Anonymous-Function]::[python]

File Name : Powers_2_Using_Anonymous_Function.jpg

# Display the powers of 2 using anonymous function

terms = 10

# Uncomment code below to take input from the user
# terms = int(input("How many terms? "))

# use anonymous function
result = list(map(lambda x: 2 ** x, range(terms)))

print("The total terms are:",terms)
for i in range(terms):
   print("2 raised to power",i,"is",result[i])

Output :

Powers_of_2_Using_Anonymous_Function.jpg