set decimal place
David Lees
debl2nononospammywhammy at bellatlantic.net
Tue Dec 25 20:34:10 EST 2001
>>> print '%8.1f' % (17.0/4)
4.3
>>> print '%8.4f' % (10.0/4)
2.5000
>>> print '%8.2f' % (20.0/7)
2.86
>>> print '%8.5f' % (20.0/7)
2.85714
David Lees
kwsiew at tm.net.my wrote:
>
> is there a way(or any function) to set decimal place in python(to any
> decimal place I want)
> example :
> 1)17.0/4 = 4.25 (but I want it to be 4.3)
> 2)10.0/3 = 3.3333333333333335 (I want 3.3333 - 4 decimal place)
> 3) 20.0/7 = 2.8571428571428572( I want 2.86 or 2.85714)
>
> thank you
> rgds,
> SKW
More information about the Python-list
mailing list