round() is Python's built-in function for rounding numbers. It uses "round half to even" (also known as bankers' rounding), meaning numbers ending in .5 are rounded to the nearest even integer. For example:

  • round(2.5)2

  • round(3.5)4

To round to a specific number of decimal places, pass the desired number as the second argument:

  • round(3.14159, 2)3.14

For rounding up to the nearest integer, use math.ceil():

  • import math; math.ceil(3.2)4

For rounding down, use math.floor():

  • import math; math.floor(3.7)3

To round up to a specific decimal place, combine multiplication, math.ceil(), and division:

import math
def round_up(num, dec=0):
    mult = 10 ** dec
    return math.ceil(num * mult) / mult
round_up(2.543, 2)  # → 2.55

The math module provides ceil(), floor(), and trunc() for precise control over rounding behavior.

The math.ceil (ceiling) function returns the smallest integer higher or equal to x.

For Python 3:

import math
print(math.ceil(4.2))

For Python 2:

import math
print(int(math.ceil(4.2)))
Answer from Steve Tjoa on Stack Overflow
🌐
W3Schools
w3schools.com › python › ref_func_round.asp
Python round() Function
Built-in Modules Random Module ... Python Training ... The round() function returns a floating point number that is a rounded version of the specified number, with the specified number of decimals....
🌐
Python
docs.python.org › 3 › library › math.html
math — Mathematical functions
3 weeks ago - The intent of the C standard is that fmod(x, y) be exactly (mathematically; to infinite precision) equal to x - n*y for some integer n such that the result has the same sign as x and magnitude less than abs(y). Python’s x % y returns a result with the sign of y instead, and may not be exactly computable for float arguments. For example, fmod(-1e-100, 1e100) is -1e-100, but the result of Python’s -1e-100 % 1e100 is 1e100-1e-100, which cannot be represented exactly as a float, and rounds to the surprising 1e100.
🌐
Mimo
mimo.org › glossary › python › round-function
Python round(): Rounding Numbers in Python
Using a negative value for the ndigits parameter, the round() function can round a floating-point number or integer to a multiple of 10. In the following example, we round 12345 to the nearest hundred (12300), simplifying the value. ... Python’s round() function works well in many cases.
🌐
Inspector
inspector.dev › home › round up numbers to integer in python – fast tips
Round Up Numbers to Integer in Python - Inspector.dev
June 17, 2025 - So I can also count the usage of a portion of a slot. This is just an example of the cool things that can be done rounding numbers. ... The simplest way to round a number in Python is to use the built-in round() function.
🌐
Server Academy
serveracademy.com › blog › python-round-function-tutorial
Python Round() Function Tutorial - Server Academy
Rounding numbers is a common operation in Python, especially when working with floating-point numbers. Python’s round() function makes it easy to round numbers to a specified number of decimal places or the nearest integer. Whether you need to round up, round down, or round to a specific decimal point, Python…
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › python › round-function-python
round() function in Python - GeeksforGeeks
Python round() function is a built-in function available with Python. It will return you a float number that will be rounded to the decimal places which are given as input. If the decimal places to be rounded are not specified, it is considered ...
Published   August 7, 2024
🌐
Real Python
realpython.com › python-rounding
How to Round Numbers in Python – Real Python
December 7, 2024 - To implement the rounding half up strategy in Python, you start as usual by shifting the decimal point to the right by the desired number of places. At this point, though, you need a way to determine if the digit just after the shifted decimal point is less than or greater than or equal to 5. One way to do this is to add 0.5 to the shifted value and then round down with math.floor().
🌐
Medium
medium.com › @ElizavetaGorelova › rounding-in-python-choosing-the-best-way-c20c2a37fe29
Rounding in Python: Choosing The Best Way | by Elizaveta Gorelova | Medium
March 15, 2024 - In general, it looks like this: round(number, digits). In the first argument (number) we pass a fractional number, and in the second (digits) we indicate the number of numbers after the decimal point.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-round-numbers-in-python
How to Round Numbers in Python? - GeeksforGeeks
July 15, 2025 - If we want to round up to a specified decimal place, you can combine multiplication, math.ceil(), and division.
🌐
Python.org
discuss.python.org › python help
Trying to understand rounding - in python - - Python Help - Discussions on Python.org
June 17, 2023 - hello @all, I’m new here, pls. be tolerant if I harm habits I don’t know about, I’m working on bin-FP-math imprecisions, and was pointed by Steven D’Aprano that python is doing a good job - from a decimal POV - in rounding >>> round(0.30000000000000004, 16) 0.3 https://mail.gnome.org/archives/gnumeric-list/2021-July/msg00019.html ( where standard FP algorithms fail to 0.3000000000000001 reg. scaling up =0.30000000000000004 by 10^16 → 3000000000000000.5 ) searching in the forum I found th...
🌐
InterServer
interserver.net › home › programming › python round() function explained: examples, decimals, and best practices
Python round() Function Explained: Examples, Decimals, and Best Practices - Interserver Tips
October 1, 2025 - Python makes rounding numbers simple with its built-in round() function. This function can round numbers to the nearest whole number or to a specific number of decimal places. You don’t need to write long code or use complex math.
🌐
Codecademy
codecademy.com › docs › python:numpy › math methods › .round()
Python:NumPy | Math Methods | .round() | Codecademy
June 18, 2024 - Rounds a number or an array of numbers to a specified number of decimal places.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-round-numbers-up-or-down-in-python
Python Round to Int – How to Round Up or Round Down to the Nearest Whole Number
May 24, 2022 - We'll start with the round() function. By default, it rounds a number to the nearest whole number. We'll also see how to use the function's parameters to change the type of result returned to us.
🌐
DataCamp
datacamp.com › tutorial › python-round-up
How to Round Up a Number in Python | DataCamp
July 22, 2024 - Discover three techniques to round up numbers in Python: using Python round up methods like math.ceil() from the math module, the decimal module, and NumPy.
🌐
Reddit
reddit.com › r/learnpython › python round() function
r/learnpython on Reddit: Python Round() Function
July 9, 2021 -

Greetings,

Code: x = round(7.85, 2) print(x)

Result: 7.8

Why is that? Rounding down starts at 0 and ends at 4, and rounding up begins at 5 and ends at 9. The result should be 7.9.

Does Python have its own math rules? If so, why? Math is math...

Please and thank you ☺

🌐
LabEx
labex.io › tutorials › python-how-to-round-up-numbers-in-python-418689
How to round up numbers in Python | LabEx
In Python, rounding helps you convert floating-point numbers to integers or limit decimal places based on specific rules. There are several common rounding methods in Python:
🌐
Udemy
blog.udemy.com › home › using the round() function in python with floor and ceil
How to Use the Round() Function in Python - Udemy Blog
April 1, 2022 - You don’t need to import math to use the ROUND() function, but you do need to import math to use the other functions mentioned. Make sure that you’re rounding to the nearest integer. If you don’t specify the number of decimal places, Python will round to the nearest whole number.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-round-to-2-decimal-places-in-python
How to Round to 2 Decimal Places in Python
August 22, 2022 - It means that you round up a number at a decimal place based on the number after it.
🌐
Python.org
discuss.python.org › ideas
Rounding to significant figures - feature request for math library - Ideas - Discussions on Python.org
June 9, 2022 - The python standard library doesn’t have any function (that I am aware of) to round a number to a number of significant figures. This is a very useful thing to be able to do and I have written a simple function to do it for 2-3 projects now. In the math library we have functions such as round(), ceil() etc, but nothing for rounding to a number of significant figures.