Python Program to Display Powers of 2 Using Anonymous Function

preview_player
Показать описание
#BackCoding

display powers of the integer 2 using Python anonymous function

used an anonymous (lambda) function inside the map() built-in function to find the powers of 2.

#python
#shorts
#dcoder
Рекомендации по теме
Комментарии
Автор

def createTable(terms):
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])


userData=int(input("Enter number of row : "))
createTable(userData)

BackCoding