Programs

# Python Program for Floor Function

The math.floor function Python is one of the math functions contained in the math library of Python. The math.floor function in Python returns the smallest integer value less than or identical to the defined expression or value.

## Syntax of the Floor Function

The floor Function in the Python math library has the following syntax:

math.FLOOR(Expression)

Check Out upGrad’s Data Science Courses

### Floor Function Number Theory

math.floor(x)

The x’s floor which is the greatest integer but less than or same as x is returned.

Syntax:

import math

math.floor(x)

Parameter:

x-numeric expression.

Returns:

An integer that is largest but not more than x.

The Python’s floor function returns an integer value close to the given numeric value. However, the returned integer value should be  equal to or less than the given numeric value. Let me show you a straightforward example of a floor function that returns the closet value of three numbers given below.

The floor() method in Python is implemented as follows

# prints the ceil using floor() method

print “math.floor(-23.11) : “, math.floor(-23.11)

print “math.floor(300.16) : “, math.floor(300.16)

print “math.floor(300.72) : “, math.floor(300.72)

## Explore our Popular Data Science Courses

 Executive Post Graduate Programme in Data Science from IIITB Professional Certificate Program in Data Science for Business Decision Making Master of Science in Data Science from University of Arizona Advanced Certificate Programme in Data Science from IIITB Professional Certificate Program in Data Science and Business Analytics from University of Maryland Data Science Courses

### Output

math.floor(-23.11) : -24.0

math.floor(300.16) : 300.0

math.floor(300.72) : 300.0

### Difference between int and floor Function in Python

Python’s floor() function returns a float value. Int() returns an integer (and in some cases, an overflow error). There may be a few explanations why having floor() might be helpful.

• floor() is the mathematical floor function and int() is equivalent to sgn(x)|x| in math
• When negative numbers are used the distinction is clear.

## Top Data Science Skills to Learn in 2022

 SL. No Top Data Science Skills to Learn in 2022 1 Data Analysis Course Inferential Statistics Courses 2 Hypothesis Testing Programs Logistic Regression Courses 3 Linear Regression Courses Linear Algebra for Analysis

Example:

bring in math

math.floor(-3.5)

-4

int (-3.5)

-3

## Read our popular Data Science Articles

 Data Science Career Path: A Comprehensive Career Guide Data Science Career Growth: The Future of Work is here Why is Data Science Important? 8 Ways Data Science Brings Value to the Business Relevance of Data Science for Managers The Ultimate Data Science Cheat Sheet Every Data Scientists Should Have Top 6 Reasons Why You Should Become a Data Scientist A Day in the Life of Data Scientist: What do they do? Myth Busted: Data Science doesn’t need Coding Business Intelligence vs Data Science: What are the differences?

Negative numbers are rounded down to get closer to 0 while truncating them gets them closer to 0.

To look at it another way, the floor() would still be less than or identical to the original. Int() will return a value that is closer to zero or equal.

If you are curious to learn about tableau, data science, check out IIIT-B & upGrad’s Executive PG Programme in Data Science which is created for working professionals and offers 10+ case studies & projects, practical hands-on workshops, mentorship with industry experts, 1-on-1 with industry mentors, 400+ hours of learning and job assistance with top firms. ## Prepare for a Career of the Future

### Data Science Skills to Master  