Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python Number round() Function


previous next AddThis Social Bookmark Button


Description:

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

Syntax:

round( x [, n]  )

Parameters:

Here is the detail of parameters:

  • x: This is a numeric expression.

  • n: This is also a numeric expression.

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 Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names