Rounding

Chris cwitts at gmail.com
Tue Dec 18 04:08:43 EST 2007


On Dec 18, 10:53 am, "Vladimir Rusinov" <vladi... at greenmice.info>
wrote:
> On 12/15/07, katie smith <iceboy... at yahoo.com> wrote:
>
>
>
> > if i have a number 6.345 and i wanted it to be 6 without subtracting .345
> > because it won't always be .345 what do i do?
>
> > how do i round to the nearest whole number. Or in this case round down. Is
> > there an easy way to round down to the nearest whole number?
>
> init() ?
>
> --
> Vladimir Rusinov
> GreenMice Solutions: IT-решения на базе Linuxhttp://greenmice.info/

You can either do:

input_number = 6.345
from math import floor
floor( input_number )
>>> 6.0
"""This will return a float rounded down.

   or alternatively"""
int( input_number )
>>> 6
"""Which will return an integer data-type."""



More information about the Python-list mailing list