how to round off to the nearest 2 decimal places phython code example
Example 1: round down decimal python
import math
val = 3.14
math.floor(val) # rounds down --> 3
math.ceil(val) # rounds up val --> 4
Example 2: how to round a decimal to the nearest whole number in python
>>> import math
>>> math.ceil(1.2)
2
>>> math.ceil(2)
2
>>> math.ceil(-0.5)
0