math.floor()

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Feb 29, 2024
Contribute to Docs

The math.floor() function takes in a numeric data type and rounds the value down to the nearest integer.

Syntax

math.floor(n)

The math.floor() function takes in a value and returns its floor, the smallest integer greater than or equal to that value.

Example

Here’s an example of math.floor() to return the floor of 134.2:

import math
print(math.floor(134.2))

The above code give the following output:

134

Codebyte Example

The following example is runnable and uses the math.floor() function to return the floor of a number:

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy