Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

How to Find Round Up Value Using ceil Function in Python

Python ceil() function exists in standard math library of Python. By using this function, we can get the ceiling value of any number. Ceiling means to round the number up to the nearest integer.
Example: What is the ceiling of 3.4 in the following:

Python ceil() Function Exmple in Python Programming language

In the above number line, the ceiling (round up) value of 3.4 is 4.
In Python, we can attain ceiling value of 3.4 by applying math.ceil() function.

Note: This function cannot be accessed directly. We need to import math library first, then we call this function as a static function of Python math library.

 

Python ceil() Function Syntax

The syntax of ceil() function in Python is:

math.ceil(n)

 

Python ceil() Function Parameter

Parameter n is any number.
In this function, the parameter n is required.

 

Python ceil() Function Compatibility

Python 2.x – Yes
Python 3.x – Yes

 

Python ceil() Function Return Value

The function will return ceiling value (round up to the nearest integer) of numeric expression n. The return value is not less than n, instead, it is equal to or greater than n.

 

Python ceil() Function Examples


ceil() Function Output:
4
1
0
2
6
-6
-6

Loading...
LearnAndLearn.com © 2018 - All rights reserved