[portland] Step Value in range()
kirby urner
kirby.urner at gmail.com
Fri May 2 18:40:24 CEST 2008
The popular Numeric package, also NumPy, has arange as a built-in,
allowing just what you suggest.
I like installing VPython (Visual Python) from VPython.org, as that'll
give you a working Numeric right out of the box, plus these other cool
tools, including plots (very simple, but there're plenty of other
add-ons for fancy).
Relevant (sort of):
http://mybizmo.blogspot.com/2008/04/plotting-with-vpython.html
http://controlroom.blogspot.com/2008/04/sa-classnotes-2008426.html
Or do stuff like:
for x in [(1.00 + n * 0.01) for n in range(11)]
'n stuff.
Kirby
IDLE 1.2.1
>>> [(1.00 + n * 0.01) for n in range(11)]
[1.0, 1.01, 1.02, 1.03, 1.04, 1.05, 1.0600000000000001,
1.0700000000000001, 1.0800000000000001, 1.0900000000000001,
1.1000000000000001]
On Fri, May 2, 2008 at 9:00 AM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> Is it possible to write a range() call with a less-than-integral step?
> Specifically, I would like to call range(0.0, 100.0, 0.1). It seems this is
> not allowed; only integers need apply.
>
> Any way of using floats in range()?
>
> Rich
>
> --
> Richard B. Shepard, Ph.D. | Integrity Credibility
> Applied Ecosystem Services, Inc. | Innovation
> <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
> _______________________________________________
> Portland mailing list
> Portland at python.org
> http://mail.python.org/mailman/listinfo/portland
>
More information about the Portland
mailing list