How to use ceil () in Python

Source: Internet
Author: User
This article describes how to use the ceil () method in Python. it is a required method for getting started with Python. For more information, see ceil () method returns the maximum value of x-the smallest integer not less than x.
Syntax

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

Import mathmath. ceil (x)

Note: This function cannot be directly accessed. Therefore, we need to import the math module and then use the static object of math to call this function.
Parameters

X -- this is a numeric expression.

Return value

This method returns the smallest integer not less than x.
Example

The following example shows how to use the ceil () method.

#! /Usr/bin/pythonimport math # This will import math moduleprint "math. ceil (-45.17): ", math. ceil (-45.17) print "math. ceil (1, 100.12): ", math. ceil (100.12) print "math. ceil (1, 100.72): ", math. ceil (100.72) print "math. ceil (119L): ", math. ceil (119L) print "math. ceil (math. pi): ", math. ceil (math. pi)

When we run the above program, it will produce the following results:

Math. ceil (-45.17):-45.0math.ceil (100.12): 101.0math.ceil (100.72): 101.0math.ceil (119L): 119.0math.ceil (math. pi): 4.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.