Message from Python discussions

November 2018

— No problrm

— 

Can somebody help me with rounding off a floating number. Like I want to round off
0.7 to 0
1.5 to 1
1.9 to 1
which function should I use?

— X= 0.6
y= int(x)

— Round()

— Type casting will just truncate the value after decimal

— Not needed if he's just truncating the value after decimal

— Round()

— Language:

py3


Source:
from math import floor
num = 1.5
floored = floor(num)
print(floored)


Result:
1

Message permanent page

— Use math.floor

— Its python devs telegram chanell of kazakhstan

— Try n = int(4.5)

— !otherlanguages