mihalybaci
June 2nd, 2011, 11:29 PM
How do you perform arithmetic with arrays of floating point numbers in Python? Forgive me if this seems like a simple problem, but I've only just begun learning Python. In IDL the syntax is pretty simple:
x = [1.0,2.0,3.0]
y = x+0.5 ; gives y = [1.5,2.5,3.5]
z = x*x ; gives z = [1.0,4.0,9.0]
I just can't seem to figure out how to do this Python. I've spent some time reading about the ARRAY module, but that didn't help.
Also as an aside, I have Python3.2 installed, but the default is still v2.7, so the packages I install (e.g. Enthought Python Distribution) are directed to 2.7 not 3.2. Is there a way to make Python3.2 the default for my system? I'm running Ubuntu 11.04.
Thanks for any help.
x = [1.0,2.0,3.0]
y = x+0.5 ; gives y = [1.5,2.5,3.5]
z = x*x ; gives z = [1.0,4.0,9.0]
I just can't seem to figure out how to do this Python. I've spent some time reading about the ARRAY module, but that didn't help.
Also as an aside, I have Python3.2 installed, but the default is still v2.7, so the packages I install (e.g. Enthought Python Distribution) are directed to 2.7 not 3.2. Is there a way to make Python3.2 the default for my system? I'm running Ubuntu 11.04.
Thanks for any help.