Python round function

In this post, we will see about Python round().
Python round() returns the floating point number rounded off to the given ndigits digits after the decimal point. If you don’t provide ndigits, it is rounded off to the nearest integer.


Syntax


Return

It returns

  • Integer if ndigits is omitted
  • same data type as num rounded to ndigits

Example

Let’s see a very simple example:

#ndigits is omitted print(round(10.234)) print(round(11.78)) #ndigit is provided print(round(10.234,2)) print(round(11.7836,3))

Output:

10
12
10.23
11.784

That’s all about round function in python.

Leave a Reply

Your email address will not be published. Required fields are marked *