ceil() function in python by R4R Team

ceil() in python is a build-in function which find the upper bound value of the given number.>

Example-
number is 3.2
required value is 4

number is 45.6
required value is 46

program-

import math
print("Enter any number")
n=float(input())
print("Ceil is "+str(math.ceil(n)))
print(type(n))
print(type(math.ceil(n)))


output-

Enter any number
3.2
Ceil is 4
<'class 'float'>
<'class 'int'>

Enter any number
45.7
Ceil is 46
<'class 'float'>
<'class 'int'>

Enter any number
-2.3
Ceil is -2
<'class 'float'>
<'class 'int'>


-In this program, we take a input of float number and try to find it ceil which is greatest or equal integer as shown in above example.
-We use math library here by import math , because ceil() function is defined in this library.If we use ceil() function without importing the math library then it will give an error undefined symbol ceil.
Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!