Python – How to round UP a number

floating-pointintegerpythonrounding

How does one round a number UP in Python?

I tried round(number) but it rounds the number down. Example:

round(2.3) = 2.0 

and not 3, as I would like.

The I tried int(number + .5) but it round the number down again! Example:

int(2.3 + .5) = 2

Best Solution

The ceil (ceiling) function:

import math
print(int(math.ceil(4.2)))