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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top