Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
math
floor
communitycreator

What is math.floor() in Python?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The floor() function returns the next largest integer less than or equal to a number. Figure 1 below shows the mathematical representation of the floor() function.

Figure 1: Mathematical representation of floor() function

The math module is required for this function.

Syntax

floor(number)

Parameter

This function requires a number to round down as a parameter.

Return value

The floor() function returns the next largest integer less than or equal to the number set as a parameter.

Example

import math
#positive integer sent as parameter
print "floor(10) : ", math.floor(10)
#negative integer sent as parameter
print "floor(-10) : ", math.floor(-10)
#positive float value sent as parameter
print "floor(2.1) : ", math.floor(2.1)
#negative float value sent as parameter
print "floor(-2.1) : ", math.floor(-2.1)

RELATED TAGS

python
math
floor
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring