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]


Expert's answer

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!

LATEST TUTORIALS
APPROVED BY CLIENTS