Answer to Question #186791 in Python for desmond

Question #186791

Use a for loop and the list append method to generate the powers of 2 to produce the following result [1, 2, 4, 8, 16, 32, 64, 128]


1
Expert's answer
2021-04-30T17:24:58-0400
n=8
power_list=[]
for i in range(0,n):
    power_list.append(2**i)
print(power_list)

Output:

[1, 2, 4, 8, 16, 32, 64, 128]

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS