Rounding numbers is a common operation in programming and mathematics. In this blog post, we will investigate how to make Python round up any decimal number to the closest integer.

## Using `math.ceil()`

Python’s ** math** module provides a function called

**(short for “ceiling”) that allows you to round up any number. Let’s see an example:**

`ceil()`

import math number = 4.35 rounded = math.ceil(number) print(rounded) # Output: 5

In this example, we first import the ** math** module and then use its

**function to round up the number**

`ceil()`

**to the closest integer, which is**

`4.35`

**.**

`5`

## Using Custom Function

If you don’t want to use the ** math** module, you can create your own function to round up numbers. Here’s an example:

def round_up(number): return int(number + (1 - (number % 1)) % 1) number = 4.35 rounded = round_up(number) print(rounded) # Output: 5

In this example, we declare a custom function called ** round_up()** that takes a number as input, calculates the remainder with

**, adds**

`number % 1`

**minus the remainder to the number, and then converts the result to an integer using the**

`1`

**function.**

`int()`

## Conclusion

Now you know how to make Python round up any decimal number to the closest integer. The most straightforward and recommended method is to use the ** math.ceil()** function from the

**module, but you can also create your own custom function if needed. Happy coding!**

`math`