1import math
2x = 3.86356
3math.floor(x)
4#Returns: 3
5math.ceil(x)
6#Returns: 4
1>>> from __future__ import division # a/b is float division
2>>> from math import ceil
3>>> b = 3
4>>> for a in range(-7, 8):
5... print(["%d/%d" % (a, b), int(ceil(a / b)), -(-a // b)])
6...
7['-7/3', -2, -2]
8['-6/3', -2, -2]
9['-5/3', -1, -1]
10['-4/3', -1, -1]
11['-3/3', -1, -1]
12['-2/3', 0, 0]
13['-1/3', 0, 0]
14['0/3', 0, 0]
15['1/3', 1, 1]
16['2/3', 1, 1]
17['3/3', 1, 1]
18['4/3', 2, 2]
19['5/3', 2, 2]
20['6/3', 2, 2]
21['7/3', 3, 3]
22