# Ceiling of a number in Python

In this tutorial, we will learn how to find Ceiling of a number in Python. Python comes with a module named math, which provides different methods that make our task of programming quite easy.

**Ceiling Number: **A number which is least greater than the given number can be termed as a ceiling of a given number, for an example

let’s say we have 3.4 and we want to find its ceiling value, the least number which is greater than 3.4 is 4.

To access this method ceil(), we have to import a module named **math** in our program. This module comes with various methods and functionalities which makes the task of a programmer easy. To know more about the functionalities of math module Click here.

## ceil() function in Python

Now, let’s do some coding in Python to understand this ceil() function more thoroughly.

import math

here we have imported the module of Python named **math.**

num=float(input("Enter the number "))

This statement takes the input from the user and casts it into a float value. This casting is quite important because whenever we apply a ceil() to an integer it makes no difference to the number. ceil() method is mainly used for floating-point numbers. The ceiling of a number can also be termed as an upper bound of a number which only makes sense when applied with a floating-point number. So we have to cast a number into float before tacking its ceiling.

ceil=math.ceil(num) print(f"Ceiling of {num} is {ceil}")

ceil() function takes one argument,

math.ceil(arg), where arg->The number for which we want to find the ceiling.

Output:

Enter the number 5.6 Ceiling of 5.6 is 6

Thus, we have successfully understood the concept of ceiling of a number and implemented it in Python.

## Leave a Reply

You must be logged in to post a comment.