+ 1
Alguien me puede decir un código para redondear flotantes
8 ответов
0
x= round (4.517, 0)
f=(int(x))
print (f)
y=round (4.137, 0)
d=(int(y))
print (d)
I got it, thanks for the help
+ 2
Python has a function called, round
round (0.6555, 2) will yield 0.66
+ 2
round(3.14159, 2) == 3.14
int(3.14) == 3
0
translate to English, might help
0
can someone tell me a code to round floating numbers
0
I hope that answers your question
0
what I want is if number is 0.5 up add 1 to it add if it is 0.4 below it will leave it the same example 4.5 =5 and 4.4= 4
0
To make matters worse or for simplicity, you can use numpy.
In [1]: import numpy as np
In [2]: x = 4.455
In [3]: np.ceil(x)
Out[3]: 5.0
In [4]: np.floor(x)
Out[4]: 4.0
Hope that helps.