"Sara Johnson" <[EMAIL PROTECTED]> wrote
> I always thought with floats you needed a 0.0.
> I do have some percentages that are less than 1% but more than 0.0.
If you already have a float value then you can compare it to an int
and
save the typing. zero means the same in a float comparison as 0.0
If you were trying to do float arithmetic, especially division, you
need to
exress at least one of the values as a float. The code you originally
posted
did that by just having a decimal point at the end - which is terrible
style - but
its more conventional (ie. more readable) to add .0 But
>fracmiss = 1.0 * numberMissing( z[key].values() ) / nsites
In this case mutiplying by 1.0 seems to be a clumsy way to ensure
a float result when
>fracmiss = float(numberMissing( z[key].values() )) / nsites
would achieve the same and be more explicit as to purpose.
Alan G
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor