• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Programming Expert

Solving All of Your Programming Headaches

  • HTML
  • JavaScript
  • jQuery
  • PHP
  • Python
  • SAS
  • Ruby
  • About
You are here: Home / Python / Ceiling Function Python – Get Ceiling of Number with math.ceil()

Ceiling Function Python – Get Ceiling of Number with math.ceil()

February 7, 2022 Leave a Comment

To find the ceiling of a number in Python, we can use the Python ceil() function from the math module. The math.ceil() Python function rounds a number up to the nearest integer.

import math 

ceiling_of_5p2 = math.ceil(5.2)

print(ceiling_of_5p2)

#Output:
6

The Python math module has many powerful functions which make performing certain calculations in Python very easy.

One such calculation which is very easy to perform in Python is finding the ceiling of a number.

We can find the ceiling of a number easily with the Python math module ceil() function.

Below are some examples of how to use math.ceil() in Python to round up and find the ceiling of numbers.

import math 

print(math.ceil(5.2))
print(math.ceil(10.8))
print(math.ceil(43.5))
print(math.ceil(-12.3))
print(math.ceil(-0.3))

#Output:
6.0
11.0
44.0
-12.0
0.0

If you want to round down and get the floor of a number in Python, you can use the math.floor() Python function. To round to the nearest integer, you can use the Python round() function.

If you are using pandas in Python you can find the ceiling of a column or Dataframe with the pandas ceil() function.

Hopefully this article has been beneficial for you to learn how to get the ceiling in Python of a number with the math.ceil() function.

Other Articles You'll Also Like:

  • 1.  How to Cube Numbers in Python
  • 2.  Python os.sep – Create Operating System Path Seperator Character
  • 3.  Python atanh – Find Hyperbolic Arctangent of Number Using math.atanh()
  • 4.  Reverse String with Recursion in Python
  • 5.  Python asinh – Find Hyperbolic Arcsine of Number Using math.asinh()
  • 6.  Get Substring Between Two Characters with Python
  • 7.  Convert String to List Using Python
  • 8.  Python Split Tuple into Multiple Variables
  • 9.  Swap Two Values of Variables in Python
  • 10.  Python Add Months to Datetime Variable Using relativedelta() Function

About The Programming Expert

The Programming Expert is a compilation of a programmer’s findings in the world of software development, website creation, and automation of processes.

Programming allows us to create amazing applications which make our work more efficient, repeatable and accurate.

At the end of the day, we want to be able to just push a button and let the code do it’s magic.

You can read more about us on our about page.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

About The Programming Expert

the programming expert main image

Welcome to The Programming Expert. We are a group of US-based programming professionals who have helped companies build, maintain, and improve everything from simple websites to large-scale projects.

We built The Programming Expert to help you solve your programming problems with useful coding methods and functions in various programming languages.

Search

Learn Coding from Experts on Udemy

Looking to boost your skills and learn how to become a programming expert?

Check out the links below to view Udemy courses for learning to program in the following languages:

Copyright © 2023 · The Programming Expert · About · Privacy Policy