To round up a number in Python, use the math.ceil() function from the math module. This function always rounds a number up to the nearest integer, regardless of its decimal value.

import math

number = 3.2
rounded_up = math.ceil(number)
print(rounded_up)  # Output: 4

Rounding up to a specific number of decimal places

To round up to a specific number of decimal places, multiply the number by a power of 10, apply math.ceil(), then divide by the same power of 10.

import math

def round_up(number, decimal_places=0):
    multiplier = 10 ** decimal_places
    return math.ceil(number * multiplier) / multiplier

# Example: Round 3.245 up to 2 decimal places
result = round_up(3.245, decimal_places=2)
print(result)  # Output: 3.25

Rounding up a list of numbers

Use a list comprehension with math.ceil() to round up all numbers in a list:

import math

numbers = [1.2, 2.5, 3.9, 4.1]
rounded_up_numbers = [math.ceil(num) for num in numbers]
print(rounded_up_numbers)  # Output: [2, 3, 4, 5]

Note: The built-in round() function does not always round up—it rounds to the nearest integer or decimal place. For guaranteed upward rounding, math.ceil() is the correct choice.

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
🌐
T-Mobile
careers.t-mobile.com › sr-business-analysis-manager › job › 326FA2862A8C7D54E44BBD993461A9B9
Apply for Sr Business Analysis Manager
2 weeks ago - 7-10 years Analytics experience solving analytical problems using quantitative approachesReporting & analyzing performance & data visualization (Tableau, Power BI, etc.): Advanced analytics, which includes SQL analysis of complex datasets, competitive analysis, quantitative analysis & researchExperience with Python, R, Go or similar statistics or data science language preferred.
Discussions

Guido van Rossum Interviews Thomas Wouters (Python Core Dev)
I do think the interview could use a bit more editing, it now reads more like a literal transcript and that is somewhat exhausting to read. Take this excerpt: · WHEW they literally dodged a bullet there More on news.ycombinator.com
🌐 news.ycombinator.com
11
97
1 week ago
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
[Python] Not able to round up despite having the Math.ceil function
Not too familiar with HTML and how the tags work there (but from what I'm guessing is the same SO thread you found, you seem to have the right idea). But if it's complaining on python's side, you could simply just do a round(float(form[nameOfInput]), 2). In this example, that will round 154.456 to 154.46. But that depends on if it's Flask that's complaining or the HTML complaining (again, I never work with HTML so I'm not sure where the complaint is coming from lol) More on reddit.com
🌐 r/learnprogramming
8
3
July 11, 2024
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 4, 2020
🌐
Google Cloud
cloud.google.com › run
Cloud Run | Google Cloud
This service was built with Vertex AI. You must be 18 or older to use it. Do not enter sensitive, confidential, or personal info. ... Lower continuous use of Cloud Run by purchasing Committed use discounts. ... Pay-per-use, with an always free tier, rounded up to the nearest 100 millisecond.
🌐
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....
🌐
Altcademy
altcademy.com › blog › how-to-round-up-in-python
How to round up in Python
June 13, 2023 - The easiest way to round up a number in Python is to use the ceil() function from the math module. The ceil() function takes a number as input and returns the smallest integer greater than or equal to the given number.
🌐
Home Assistant
home-assistant.io › docs › configuration › templating
Templating - Home Assistant
The last unit is rounded. For example: precision = 1 could return “2 years” while precision = 2 could return “1 year 11 months”. This function can also be used as a filter. If the datetime is in the past, returns 0 seconds. A precision of 0 returns all available units, default is 1. timedelta returns a timedelta object, which represents a duration (an amount of time between two datetimes). It accepts the same arguments as the Python datetime.timedelta function – days, seconds, microseconds, milliseconds, minutes, hours, weeks.
🌐
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 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 which rounds up and rounds down a number to the nearest whole number/integer respectively.
Find elsewhere
🌐
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.
🌐
Replit
replit.com › home › discover › how to round up in python
How to round up in Python
February 5, 2026 - The math.ceil() function is your go-to for rounding up. Since it's part of Python's built-in math module, you first need to import it with import math.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-round-numbers-in-python
How to Round Numbers in Python? - GeeksforGeeks
July 15, 2025 - Rounding up always rounds a number to the right on the number line and rounding down always rounds a number to the left on the number line. Similarly, for rounding down we can use floor() function instead of ceil():
🌐
Mimo
mimo.org › glossary › python › round-function
Python round(): Rounding Numbers in Python
For high-precision cases like accounting and scientific calculations, consider using the decimal module instead. 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
🌐
Hacker News
news.ycombinator.com › item
Guido van Rossum Interviews Thomas Wouters (Python Core Dev) | Hacker News
1 week ago - I do think the interview could use a bit more editing, it now reads more like a literal transcript and that is somewhat exhausting to read. Take this excerpt: · WHEW they literally dodged a bullet there
🌐
TradingCode
tradingcode.net › python › math › round-decimals
How to round decimal places up and down in Python? • TradingCode
But we can make our own and leverage the math.ceil() function. When we do, using the function looks like this: ... import math def round_decimals_up(number:float, decimals:int=2): """ Returns a value rounded up to a specific number of decimal places.
🌐
Learn Pain Less
learnpainless.com › how-to-round-in-python
How to Round in Python | Learn Pain Less
March 21, 2023 - This method rounds the number to the nearest integer. If the decimal is positive, the number is rounded up. If the decimal is negative, the number is rounded down. This method rounds the number to the nearest even integer.
🌐
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 ...
🌐
Python⇒Speed
pythonspeed.com › articles › speed-unit-tests
Unit testing your code’s performance, part 2: Catching speed changes
2 weeks ago - When I run the original test this way, the instruction counts have far less variation: $ export PYTHONHASHSEED=3 $ setarch x86_64 -R pytest test_speed.py ... FAILED AssertionError: assert 312713197 == 'FIXME' $ setarch x86_64 -R pytest test_speed.py ... FAILED AssertionError: assert 312713196 == 'FIXME' $ setarch x86_64 -R pytest test_speed.py ... FAILED AssertionError: assert 312713200 == 'FIXME' That means I can change the test to be more sensitive: assert round( instruction_count / 100_000 ) == 3127, "wordcount()'s speed may have changed"
🌐
Leapcell
leapcell.io › blog › how-to-round-numbers-in-python
How to Round Numbers in Python | Leapcell
July 25, 2025 - For example, round(2.5) returns 2, and round(3.5) returns 4 · For more control over rounding, especially when you need to always round up or down, Python's math module provides ceil() and floor() functions.
🌐
Server Academy
serveracademy.com › blog › python-round-function-tutorial
Python Round() Function Tutorial - Server Academy
In this tutorial, we’ll cover everything you need to know about the round() function, including how to use it, how to round up or down, and practical examples for common rounding tasks.
🌐
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 ...