Python math.floor() Function Guide

In Python, the floor() function is a function in the math module that is used to return the largest integer less than or equal to a given number.

To use the floor() function, you first need to import the math module.

import math

Then you can use the math.floor() function to round down a number, for example:

import math

num = 3.78
result = math.floor(num)
print(result)  # 输出 3

In the example above, the math.floor() function performs a floor operation on 3.78, returning a result of 3.

bannerAds