Skip to content

Commit 3d31e18

Browse files
Merge pull request #1113 from pratiksha175/patch-1
Create query #112
2 parents 0e78504 + 29cc74b commit 3d31e18

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

query #112

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Display the powers of 2 using anonymous function
2+
3+
terms = 10
4+
5+
# Uncomment code below to take input from the user
6+
# terms = int(input("How many terms? "))
7+
8+
# use anonymous function
9+
result = list(map(lambda x: 2 ** x, range(terms)))
10+
11+
print("The total terms are:",terms)
12+
for i in range(terms):
13+
print("2 raised to power",i,"is",result[i])

0 commit comments

Comments
 (0)