Rounds a number up.
Synopsis
import math
math.ceil(number)
Description
Use ceil when a part needs a whole one: 10 pupils in groups of 3 need 4 groups, not 3.
Parameters
| Name | Meaning |
|---|---|
number |
An int or a float. |
Return value
An int.
Example
import math
print(math.ceil(3.2))
print(math.ceil(10 / 3))
It prints:
4
4
Common mistake
print(10 // 3)
It prints:
3
Not an error, but a wrong answer for the groups problem: // rounds down, so one pupil is left out.
See also
Last updated 2 weeks ago