How to use floor, truncate and ceil in Python

2 Answers

0 votes
import math 

n = 3.14
print(math.floor(n));
print(math.trunc(n));
print(math.ceil(n));


  
'''
run:
  
3
3
4
         
'''

 



answered May 16, 2020 by avibootz
0 votes
import math 

n = -3.14
print(math.floor(n));
print(math.trunc(n));
print(math.ceil(n));


  
'''
run:
  
-4
-3
-3
         
'''

 



answered May 16, 2020 by avibootz

Related questions

...