Skip to content

Commit d7a9901

Browse files
authored
Merge pull request #64 from Vava145/patch-1
Create powers of 2.py
2 parents a0a4da5 + 62e1242 commit d7a9901

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

python/powers of 2.py

+13
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)