round() Round number

Last updated: 2026-09-22

round() Round number

round(number[, ndigits]) rounds using banker's rounding; ndigits=None returns an int.

CategoryBuilt-in Functions
KindBuilt-in Function
Python Versionall

📝 Syntax

round(number[, ndigits])

⚙️ Parameters

number RequiredThe number to round (int / float).
ndigits OptionalNumber of decimal places; None returns an int.(Default:None)

Returns:An int when ndigits is None; otherwise the rounded value of the same type as number (banker's rounding).

💥 Raises

▶ Example

Edit the code, press Run, and see the result in the output panel:

Output:

4
4
3.14
ℹ️ Info Python 3 uses banker's rounding to avoid long-term statistical bias.
More case studies coming soon — check back later.

❓ FAQ

QWhy is round(2.5) 2 instead of 3?
APython 3 uses banker's rounding (round half to even): an exact .5 rounds to the nearest even number, and the nearest even to 2.5 is 2; similarly round(3.5) gives 4.
QWhat does round(3.14159, 2) return?
AIt returns 3.14 — the second argument ndigits specifies the number of decimal places.
QWhat does round(123, -1) return?
AIt returns 120 — ndigits can be negative, rounding to tens, hundreds, and so on.
QIs round() exact decimal rounding?
ANo — floats have binary representation error, so round(2.675, 2) may give 2.67 rather than 2.68; for precision-sensitive values (like money) use decimal.Decimal.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏