Answers for "ceiling division python"

3

python ceiling

import math

n = 2.5

print(str(math.ceil(n)))
Posted by: Guest on January-06-2021
1

floor function in python

import math
print(math.floor(5.3))
output = 5
Posted by: Guest on June-22-2020
0

python ceiling division

>>> from __future__ import division   # a/b is float division
>>> from math import ceil
>>> b = 3
>>> for a in range(-7, 8):
...     print(["%d/%d" % (a, b), int(ceil(a / b)), -(-a // b)])
... 
['-7/3', -2, -2]
['-6/3', -2, -2]
['-5/3', -1, -1]
['-4/3', -1, -1]
['-3/3', -1, -1]
['-2/3', 0, 0]
['-1/3', 0, 0]
['0/3', 0, 0]
['1/3', 1, 1]
['2/3', 1, 1]
['3/3', 1, 1]
['4/3', 2, 2]
['5/3', 2, 2]
['6/3', 2, 2]
['7/3', 3, 3]
Posted by: Guest on August-15-2021

Python Answers by Framework

Browse Popular Code Answers by Language