Easy Tutorial
❮ Python Square Root Python Os Fstatvfs ❯

Python math.floor() Method

Python math Module

The math.floor(x) method in Python rounds x down to the nearest integer.

The math.ceil() method rounds a number up to the nearest integer.

Syntax

The syntax for the math.floor() method is as follows:

math.floor(x)

Parameter Description:

Return Value

Returns an integer int, representing the rounded-down number.

Example

The following example returns the number rounded down to the nearest integer:

Example

# Import the math package
import math

# Output the number rounded down to the nearest integer
print(math.floor(0.6))
print(math.floor(1.4))
print(math.floor(5.3))
print(math.floor(-5.3))
print(math.floor(22.6))
print(math.floor(10.0))

Output result:

0
1
5
-6
22
10

Python math Module

❮ Python Square Root Python Os Fstatvfs ❯