generating range of numbers

V

vimal

hi all,

i am new to python.....
i just want to generate numbers in the form like:

1,2,4,8,16,32.....to a maximum of 1024

using a range function
 
M

Michael Bentley

i am new to python.....
i just want to generate numbers in the form like:

1,2,4,8,16,32.....to a maximum of 1024

using a range function

I don't think it can be done with *only* a range function...

import math
[pow(2, x) for x in range(math.log(1024, 2) +1)]

hth,
Michael
 
W

Wildemar Wildenburger

vimal said:
hi all,

i am new to python.....
i just want to generate numbers in the form like:

1,2,4,8,16,32.....to a maximum of 1024

using a range function
Homework?

/W
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top