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
Python Examples Python Compiler ... 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....
Discussions

How do you round up in Python?
First, it looks like the numbers are just rounding, not specifically rounding up. Look into formatted strings . More on reddit.com
🌐 r/learnpython
7
1
January 23, 2019
Round half up Error
I need to round to the nearest whole number so 2.5 should be 3 and 2.4 should be 2. I am trying to use round_half_up to get around the round half even issue. The error I get: conversion from Series to Decimal is not supported. I’m not sure how to make this round correctly. from decimal import ... More on discuss.python.org
🌐 discuss.python.org
0
January 18, 2023
Using round_half_up to round numbers
def round_half_up(x): if x%1<.5: return int(x) return int(x) + 1 More on reddit.com
🌐 r/learnpython
8
1
March 10, 2022
Why does round(2.35, 1) return 2.4 (rounded up) but round(2.25, 1) returns 2.2 (rounded down)?
It’s a rounding method to balance error. If you always round up, it creates unbalanced weighting towards increasing. The idea is the digit in front of the 5 dictates the direction, odd rounds up while even rounds down. More on reddit.com
🌐 r/learnpython
50
237
March 7, 2020
🌐
Mimo
mimo.org › glossary › python › round-function
Python round(): Rounding Numbers in Python
If precision is critical, Python’s decimal module provides a way to avoid floating-point precision issues. The decimal module allows you to work with decimal numbers while avoiding the rounding errors of float numbers. ... from decimal import Decimal, ROUND_HALF_UP # Create Decimal objects instead of using floats num = Decimal('2.675') # Use the quantize() method to round to two decimal places with rounding mode ROUND_HALF_UP rounded_num = num.quantize(Decimal('0.01'), rounding=ROUND_HALF_UP) print(rounded_num) # Outputs: 2.68
🌐
Server Academy
serveracademy.com › blog › python-round-function-tutorial
Python Round() Function Tutorial - Server Academy
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 has you covered with its versatile round() function.
🌐
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.
🌐
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 ·
Find elsewhere
🌐
Medium
medium.com › @heyamit10 › understanding-numpy-round-up-ceil-vs-round-vs-floor-f155922395b8
Understanding NumPy Round Up (ceil vs round vs floor) | by Hey Amit | Medium
April 12, 2025 - When you’re working with numbers in NumPy, rounding is something you’ll run into all the time. But not all rounding is the same. Rounding up, rounding down, and regular rounding behave very differently — and if you’re not careful, you might end up with results you didn’t expect.
🌐
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 - The math library in Python provides the ceil() and floor() functions to round numbers up and down, respectively, to the nearest integer. These functions are useful when you need to work with integer values, especially in cases like calculating ...
🌐
Real Python
realpython.com › python-rounding
How to Round Numbers in Python – Real Python
December 7, 2024 - In Python, math.ceil() implements the ceiling function and always returns the nearest integer that’s greater than or equal to its input: ... Notice that the ceiling of -0.5 is 0, not -1. This makes sense because 0 is the nearest integer to -0.5 that’s greater than or equal to -0.5. Now write a function called round_up() that implements the rounding up strategy:
🌐
Hyperskill
hyperskill.org › university › python › rounding-and-round-in-python
Rounding and round() in Python
August 2, 2024 - If rounding to the whole number the round() function rounds up if the decimal part is 0.5 or greater and rounds down if its less, than 0.5. For instance rounding 3.2 using round(3.2) gives 3 as output; while rounding 3.5 returns 4 according to this function. The round() function, in Python ...
🌐
YouTube
youtube.com › watch
Introduction to Rounding Numbers in Python - YouTube
This is a preview of the video course, "Rounding Numbers in Python." Understanding how rounding works in Python can help you avoid biasing your dataset. This...
Published   June 20, 2024
🌐
GeeksforGeeks
geeksforgeeks.org › python › round-function-python
round() function in Python - GeeksforGeeks
import math num = 3.6 rounded_num = math.floor(num) # rounds down to nearest integer print(rounded_num) # output: 3 rounded_num = math.ceil(num) # rounds up to nearest integer print(rounded_num) # output: 4 ... In this example, we are using numpy module to round the values to their 3rd decimal places in Python.
Published   August 7, 2024
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.3 documentation
2 weeks ago - For a general Python object number, round delegates to number.__round__.
🌐
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. We'll then talk about the math.ceil() and math.floor() methods ...
🌐
YouTube
youtube.com › watch
How to Round Numbers in Python ( Not What You Expect) - YouTube
Rounding numbers in python not working as expected? Discover the nuances of rounding numbers in Python with our latest tutorial. While rounding might seem st...
Published   June 2, 2024
🌐
Python.org
discuss.python.org › python help
Round half up Error - Python Help - Discussions on Python.org
January 18, 2023 - I need to round to the nearest whole number so 2.5 should be 3 and 2.4 should be 2. I am trying to use round_half_up to get around the round half even issue. The error I get: conversion from Series to Decimal is not supported. I’m not sure how to make this round correctly. from decimal import * getcontext().prec = 1 for i in range(15, df.shape[1],2): df.iloc[:,i+1] = decimal.Decimal(df.iloc[:,i+1])
🌐
Medium
medium.com › 4geeksacademy › how-to-round-in-python-cf547f8c9376
How to Round in Python? | by 4Geeks Academy | 4GeeksAcademy | Medium
June 20, 2023 - During this article, we will see several methods in python to round numbers such as round up, round down, round to a specific decimal number and round to the nearest integer number.
🌐
Reddit
reddit.com › r/learnpython › using round_half_up to round numbers
r/learnpython on Reddit: Using round_half_up to round numbers
March 10, 2022 -

I don't want to round to the nearest even number, I just want to always round my halve up.

I just want to do something like:

import decimal print(round_half_up(2.5))

But I've figured out that's not right. How would I do that?

Edit:

If anyone is curious why. I'm graphing some data I rounded. The even numbers are clearly bigger than the odd numbers

🌐
Real Python
realpython.com › videos › rounding-numbers-up
Rounding Up (Video) – Real Python
03:34 Rounding up means moving to the right on the line. Any value that isn’t dead on an integer is going to move rightwards. For positive numbers, that means a bigger value. For negative numbers that means a smaller negative heading towards zero.
Published   June 18, 2024