>>> import math
>>> math.ceil(5.2)
6
>>> math.ceil(5)
5
>>> math.ceil(-0.5)
0
>>> import math
>>> math.floor(3.9) # round down
3
# no import needed
# take advantage of floor division by negating a and flooring it
# then negate result to get a positive / negative (depending on input a)
def round_up(a, b = 1):
return -(-a // b) # wrap in int() if only want integers
>>> round_up(3.2) # works on single digits
4.0
>>> round_up(5, 2)
3
>>> round_up(-10, 4) # works on negative numbers
-2
#math.floor(number)
import math
print(math.floor(3.319)) #Prints 3
print(math.floor(7.9998)) #Prints 7
>>> import math
>>> math.ceil(3.2) # round up
4
#To round decimals
round(123.4)
#To select the significant number you whish to round to
#add extra parameter
round(12.456, 2)
#To round whole numbers
round(1236, -1)
#int('your decimal number')
>>>> int(1.7)
1