Decimals in python

Aidan aweraw at gmail.com
Mon Jun 16 08:24:16 CEST 2008


arslanburney at gmail.com wrote:
> Hello. New to using Python. Python automatically round off watver i
> calculate using the floor function. How wud i make the exact value
> appear?
> 
> Tried out fabs() in the math library but still confused. Cud some1
> elaborate on it.

If you're working with integers, the result will always be an integer:

 >>> a = 10/3
 >>> print a
3

How ever if you add a float into the mix:

 >>> a = 10/3.0
 >>> print a
3.3333333333333335

HTH



More information about the Python-list mailing list