[Tutor] Dividing 1 by another number ?

Sean Perry shaleh at speakeasy.net
Mon Jan 31 00:25:31 CET 2005


Tony Meyer wrote:
> Dividing two integers will give you an integer (truncated) result:
> If you want '1/2' to give you 0.5 (throughout your script), you can do:
>>>>from __future__ import division
> Notice that '//' (with or without the from __future__ import) will give you
> the integer result.
> 

or more simply, divide by 4.0 for rod and bore: (rod**2/4.0)

what happens if rodarea is bigger than area?


More information about the Tutor mailing list