×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

math.floor() method with example in Python

Python math.floor() method: Here, we are going to learn about the math.floor() method with example in Python.
Submitted by IncludeHelp, on April 17, 2019

Python math.floor() method

math.floor() method is a library method of math module, it is used to get the floor value of a given number, it is used to get the floor value of a number, it accepts a number/numeric expression and returns largest integer (integral) value, which is not greater than the number.

Note: It is useful with the float values if the number is an integer value – it returns the same value.

Syntax of math.floor() method:

    math.floor(n)

Parameter(s): n – a number or numeric expression.

Return value: int – it returns an integer value – which is largest integer value of given number but not greater than the n.

Example:

    Input:
    n = 10.23

    # function call
    print(math.floor(n))

    Output:
    10

Python code to find floor value of a given number

# Python code to find floor value of a given number
# importing math
import math

# number
n1 = 10.23
n2 = 10.67
n3 = 10
n4 = -10.23
n5 = 0

# printing floor values
print("floor(n1): ", math.floor(n1))
print("floor(n2): ", math.floor(n2))
print("floor(n3): ", math.floor(n3))
print("floor(n4): ", math.floor(n4))
print("floor(n5): ", math.floor(n5))

Output

floor(n1):  10
floor(n2):  10
floor(n3):  10
floor(n4):  -11
floor(n5):  0
Advertisement
Advertisement


Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.