Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.ceil() Method

Python math.ceil() Method

Python math Module Python math Module

Python math.ceil(x) The method rounds x up to the nearest integer.

math.floor() The method rounds a number down to the nearest integer.

Syntax

The syntax of the math.ceil() method is as follows:

math.ceil(x)

Parameter Description:

Return Value

Returns an integer representing the rounded number.

Example

The following example returns values rounded up to the nearest integer:

Example

Import the math package

import

math

Output the values rounded up to the nearest integer

print

(

math

.

ceil

(

1.4

)

)

print

(

math

.

ceil

(

5.3

)

)

print

(

math

.

ceil

(

5.3

)

)

print

(

math

.

ceil

(

22.6

)

)

print

(

math

.

ceil

(

10.0

)

)

Output result:


2
6
-5
23
10

Python math Module Python math Module