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 187 views
1 answer 117 views
117 views asked Nov 29, 2022 by avibootz
1 answer 158 views
158 views asked Jun 10, 2019 by avibootz
2 answers 241 views
...