Copyright © tutorialspoint.com

Python Number round() Function

previous next


Description:

This function returns x rounded to n digits from the decimal point.

Syntax:

round( x [, n]  )

Parameters:

Here is the detail of parameters:

Return Value:

The x rounded to n digits from the decimal point.

Example:

#!/usr/bin/python

print "round(80.23456, 2) : ", round(80.23456, 2)
print "round(100.000056, 3) : ", round(100.000056, 3)
print "round(-100.000056, 3) : ", round(-100.000056, 3)

This will produce following result:

round(80.23456, 2) :  80.23
round(100.000056, 3) :  100.0
round(-100.000056, 3) :  -100.0

previous next

Copyright © tutorialspoint.com