1import math
2x = 3.86356
3math.floor(x)
4#Returns: 3
5math.ceil(x)
6#Returns: 4
1def floor(k,b):
2 return b-k%b+k-b
3
4print(floor(3,10)) # Prints: 0
5print(floor(7.94,2.125)) # Prints: 6.375
1math.floor(-23.11) : -24.0
2math.floor(300.16) : 300.0
3math.floor(300.72) : 300.0
4
1# round(number, decimals).
2# second parameter is optional, defaults to 0.
3
4num1 = 1.56234
5num2 = 1.434
6
7print(round(num1)) # output: 2
8print(round(num2)) # output: 1
9print(round(num1, 3)) # output: 1.562
10print(round(num2, 1) # output: 6.3