Python Round Up: Ceil Methods Guide

In Python, we can use the ceil() function from the math module to round up a number. The usage of this function is as follows:

import math

num = 3.14
result = math.ceil(num)
print(result)  # 输出结果为 4

Furthermore, we can also utilize the ceil() function in the math module to round a number up.

import math

num = 3.14
result = -int(-num//1)
print(result)  # 输出结果为 4
bannerAds