+ 1
Hi guy It me again I got some python questions been learning run one code I dont understand the code check it below
Import math print (math.ceil (2.434)) The answer is 3 instead of two Why?
4 Answers
+ 5
Because math.ceil rounds the value upward,
And math.floor rounds the value downward
+ 2
It is very simple. Ceil function give the integer value greater than or equal to the value provided as its parameter.
Example
math.ceil(3)
Answer. 3
math.ceil(3.1)
Answer 4
One more thing, before using any function you can check its functionality from documentation.
+ 2
Nice explanation mr khan
+ 1
ceil will always round up unless the float is exactly x.00...
for example:
import math
print(math.ceil(2.0000001))
outputs:
3