Change language

# Python floor () and ceil () function

gender ()

The floor () method in Python returns floor of x, that is, the largest integer not greater than x.

`  Syntax:  import math math.floor (x)  Parameter:  x-numeric expression.  Returns:  largest integer not greater than x. `

Below is the Python implementation of the floor () method:

 ` # Python program to demonstrate the use of the floor () method ` ` `  ` # This imports the math module ` ` import ` ` math `   ` # prints ceil using the floor () method ` ` print ` ` "math.floor (-23.11):" ` `, math.floor (` ` - ` ` 23.11 ` `) ` ` print ` ` "math.floor (300.16):" ` `, ma th.floor (` ` 300.16 ` `) ` ` print ` ` "math.floor (300.72):" ` `, math.floor (` ` 300.72 ` `) `

Output:

` math.floor (-23.11): -24.0 math.floor (300.16): 300.0 math.floor (300.72): 300.0 `

CEIL ()

The ceil () method in Python returns the ceiling x, which is the smallest integer not less than x.

`  Syntax:  import math math.ceil (x)  Parameter:  x: This is a numeric expression.  Returns:  Smallest integer not less than x. `

Below is the implementation of the ceil () method in Python:

` `

` # Python program to demonstrate using the ceil () method   # This imports the math module import math    # prints ceil using the ceil () method print "math.ceil (-23.11):" , math.ceil ( - 23.11 ) print "math.ceil (300.16):" , math.ceil (  300.16 ) print "math.ceil (300.72):" , math.ceil ( 300.72 ) `

Output:

` math.ceil (-23.11): -23.0 math.ceil (300.16): 301.0 math.ceil (300.72): 301.0 `

## Shop

Best laptop for Excel

\$

Best laptop for Solidworks

\$399+

Best laptop for Roblox

\$399+

Best laptop for development

\$499+

Best laptop for Cricut Maker

\$299+

Best laptop for hacking

\$890

Best laptop for Machine Learning

\$699+

Raspberry Pi robot kit

\$150

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

## Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically