take the ceiling of a number in python

You can use the math.ceil() function to round a number up to its nearest whole number (ceiling). Here's an example:

main.py
import math

num = 3.14
ceiling_num = math.ceil(num)

print(ceiling_num) # Output: 4
85 chars
7 lines

In this example, math.ceil(num) returns 4, which is the ceiling of the num variable, and 4 is then assigned to the ceiling_num variable. Finally, the print() function is used to display the result.

gistlibby LogSnag