# Python: Round a Float to Two Decimal Places With round()

> Round a floating point number to two decimal places in Python using the round() function, or use the decimal module to avoid floating-point rounding surprises

**URL:** https://sentry.io/answers/limit-floats-to-two-decimal-points-in-python/

---

## The Problem

How do I round a floating point number to two decimal places?

## The Solution

We can do this using Python's [`round()`](https://docs.python.org/3/library/functions.html#round) function, which rounds a given number to a specified number of decimal places. For example:

```python
my_number = 9.489999999999
rounded = round(my_number, 2)

print(rounded) # will output "9.49"
```

Due to the [limitations of floating point arithmetic](https://docs.python.org/3/tutorial/floatingpoint.html#tut-fp-issues), the `round()` may sometimes produce unexpected results. If this is undesirable, consider using the [`decimal`](https://docs.python.org/3/library/decimal.html) module as a replacement for floating point numbers.

---

*Source: [sentry.io/answers/limit-floats-to-two-decimal-points-in-python/](https://sentry.io/answers/limit-floats-to-two-decimal-points-in-python/)*
