How to round off a floating number using Python?

PythonServer Side ProgrammingProgramming

The round() function in Python's library rounds the number to given position. Following are some Examples.

>>> round(11.6912,2) # upto second decimal place
11.69
>>> round(11.6912,1) # upto first place after decimal point
11.7
>>> round(11.6912) # rounded to nearest integer
12
>>> round(11.6912,-1)#rounded to ten's place
10.0
raja
Published on 06-Mar-2018 19:59:38
Advertisements