Study Guide

4.7.6 Powers of Two CodeHS Answers

4.7.6 Powers of Two CodeHS Answers

The most common answer is:

Enter your code here
for i in range(20):
print(2**i)

This code is intended to print the powers of 2, from 20 up to 219. To ensure it adheres to Python syntax standards, here’s your code formatted correctly:

for i in range(20):
print(2**i)

This code will output the first 20 powers of 2, starting with 20 and ending with 219. Each power of 2 is calculated by raising 2 to the power of i, where i ranges from 0 to 19.