Re: generating range of numbers

2007-10-03 Thread Wildemar Wildenburger
vimal wrote: > 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 -- http://mail.python.org/mailman/listinfo/python-list

Re: generating range of numbers

2007-10-03 Thread Michael Bentley
On Oct 3, 2007, at 2:18 AM, vimal wrote: > 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

Re: generating range of numbers

2007-10-03 Thread Amit Khemka
On 10/3/07, vimal <[EMAIL PROTECTED]> wrote: > 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 [2**i for i in range(11)] This is a list comprehension, for more have a lo

Re: generating range of numbers

2007-10-03 Thread Andreas Tawn
>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 >>> a = [2**x for x in range(11)] >>> a [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024] Cheers, Andreas Tawn Lead Technical Artist Ubisoft Reflections -- http://mail.python.org/ma

generating range of numbers

2007-10-03 Thread 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 -- http://mail.python.org/mailman/listinfo/python-list