From 0c8296f27e080b0d0fec7cec99081dfdbe5c06b9 Mon Sep 17 00:00:00 2001 From: MOHAMMED SHAHEER V K <72807702+kavyaS143@users.noreply.github.com> Date: Sun, 30 Oct 2022 14:44:00 +0530 Subject: [PATCH] Create powers of 2.py pls merge with hacktoberfest label --- powers of 2.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 powers of 2.py diff --git a/powers of 2.py b/powers of 2.py new file mode 100644 index 0000000..5ac0e09 --- /dev/null +++ b/powers of 2.py @@ -0,0 +1,13 @@ +# 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])