Round
Diez B. Roggisch
deets at nospam.web.de
Sun Apr 9 08:16:20 EDT 2006
HeidiWeber wrote:
> Hello
>
> i´m a beginner in python. With version 14 in SPSS (statistic software)
> there are the posibility to use python.
>
> i want do the following:
>
> double NCases
> NCases=10/6
>
> is this correct in python? Because in SPSS there are an error message.
No, its not correct in python. In python, you don't declare the type of a
variable. You statement above would simply be
NCases = 10.0 / 6.0
Note the float-literals! If you wouldn't use these, the result would not be
~1.6, but 1 instead, because integer division yields only integers.
Depending on which version of python SPSS ships, you should be able to make
the division-operator / enforce the usage of floats by putting
from __future__ import division
on top of your script.
Diez
More information about the Python-list
mailing list