Alternatively, in the numpy module (part of the Scientific Tools for Python http://www.scipy.org/ ) there is the linspace function, which you could use like this for x in numpy.linspace(0,2,21): print(x)
Russell On 23 August 2012 14:34, Ricardo Franco <[email protected]> wrote: > Well, this is a good idea, I go do this way. tks > > > 2012/8/22 Greg Ewing <[email protected]> > >> Ricardo Franco wrote: >> >>> That's why when you are comparing floating point numbers, you always >>> have to check if they are within some small error value from each >>> other. How large that value is depends on your particular use case. >>> >> >> It's even better if you can avoid comparing floats for >> equality at all. You can do that in this case by using an >> integer loop counter and computing the float value from it: >> >> >>> for i in xrange(11): >> ... rate = 1.0 + i * 0.1 >> ... print rate >> ... >> 1.0 >> 1.1 >> 1.2 >> 1.3 >> 1.4 >> 1.5 >> 1.6 >> 1.7 >> 1.8 >> 1.9 >> 2.0 >> >> -- >> Greg >> > > > > -- > Ricardo Franco Andrade @ricardokrieg > > ( Game | Desktop | Web ) Developer > > email: [email protected] > contact: +55 (86) 9958 9725 > +55 (86) 9436 0830 > twitter: twitter.com/ricardokrieg > facebooK: https://www.facebook.com/krieg.ricardo > github: https://github.com/ricardokrieg > >
