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 311 views
1 answer 194 views
194 views asked Nov 29, 2022 by avibootz
1 answer 250 views
250 views asked Jun 10, 2019 by avibootz
2 answers 368 views
...