Hi guy It me again I got some python questions been learning run one code I dont understand the code check it below | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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?

29th Aug 2020, 3:07 PM
victor bamidele
victor bamidele - avatar
4 Answers
+ 5
Because math.ceil rounds the value upward, And math.floor rounds the value downward
29th Aug 2020, 3:13 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 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.
29th Aug 2020, 3:12 PM
Muhammad Bilal
Muhammad Bilal - avatar
+ 2
Nice explanation mr khan
29th Aug 2020, 3:15 PM
victor bamidele
victor bamidele - avatar
+ 1
ceil will always round up unless the float is exactly x.00... for example: import math print(math.ceil(2.0000001)) outputs: 3
29th Aug 2020, 3:12 PM
Steven M
Steven M - avatar