Powers of two

Created by Julien Palard

Print the 10 first powers of two, one per line. (beware: not the first squares!)

Start at 0, so the first power of two is 20 (which happen to be one), followed by 21, 22, and so on up to 29.

As a reminder, the power operator in Python is written **, so:

>>> 2 ** 5
32

Advices

You'll need a for statement to iterate over the range function.

The for statement is a tool to traverse things containing items. Strings, lists, and ranges are things containing items, so you can use a for to iterate their elements, like:

>>> for c in "Hello":
...     print("The letter is", c)
...
The letter is H
The letter is e
The letter is l
The letter is l
The letter is o

Or like:

>>> for i in [1, 10, 100, 1000]:
...     print(i)
...
1
10
100
1000

Or:

>>> for i in range(10):
...     print(i * 2)
...
0
2
4
6
8
10
12
14
16
18

There's no corrections yet, hit the `Submit` button to send your code to the correction bot.

Keyboard shortcuts:

  • Ctrl-Enter: Send your code to the correction bot.
  • Escape: Get back to the instructions tab.

See solutions