How to use floor and ceil with fraction in Python

1 Answer

0 votes
from fractions import Fraction as frac
import math

print('floor: ' + str(math.floor(frac('31/4'))))
print('ceil: ' + str(math.ceil(frac('31/4'))))


'''
run:

floor: 7
ceil: 8

'''

 



answered Jun 10, 2019 by avibootz

Related questions

2 answers 315 views
1 answer 201 views
201 views asked Nov 29, 2022 by avibootz
1 answer 256 views
256 views asked Jun 10, 2019 by avibootz
2 answers 372 views
...