0
How does the function floor work ?
11 Antworten
+ 4
round() rounds to closest int (1.4 = 1, 1.6 = 2)
+ 3
you mean floor() method? It rounds numbers towards smaller int. (1.4 = 1, 1.9 = 1)
+ 3
floor(1.259647)
+ 3
ceil() to biggest ...
+ 3
"floor" follows the mathematical definition for "integer part": it's the largest integer that is smaller than the given value. So watch it! For negative numbers, it's not about dropping the decimal part:
from math import floor
print(floor(2.4)) # 2
print(floor(-2.4)) # -3
+ 2
Is it the same as ' .round() '?
+ 1
If i have 1.259647 for exemple how can i have only 1 ? .floor(1.259647) ?
+ 1
?
+ 1
yes but how is the exect way to use it ? floor(x), floor.x , floor"x" ?
+ 1
i'm just starting to code with python
+ 1
ok thank you