You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11 lines
367 B
Python

# Python Program to display the powers of 2 using anonymous function
# Take number of terms from user
terms = int(input("How many terms? "))
# use anonymous function
result = list(map(lambda x: 2 ** x, range(terms)))
# display the result
for i in range(terms):
print("2 raised to power",i,"is",result[i])