How to use floor in python

藏色散人
Release: 2019-06-22 13:39:48
Original
4511 people have browsed it

How to use floor in python

python floor() returns the rounded down integer of a number.

The following is the syntax of the floor() method:

import math math.floor( x )
Copy after login

Note: floor() cannot be accessed directly. You need to import the math module and call the method through a static object. .

Parameters

x -- Numeric expression.

Return value

Returns the rounded integer of the number.

The following shows an example of using the floor() method:

#!/usr/bin/python import math # This will import math module print "math.floor(-45.17) : ", math.floor(-45.17) print "math.floor(100.12) : ", math.floor(100.12) print "math.floor(100.72) : ", math.floor(100.72) print "math.floor(119L) : ", math.floor(119L) print "math.floor(math.pi) : ", math.floor(math.pi)
Copy after login

The output result after running the above example is:

math.floor(-45.17) : -46.0 math.floor(100.12) : 100.0 math.floor(100.72) : 100.0 math.floor(119L) : 119.0 math.floor(math.pi) : 3.0
Copy after login

Related recommendations: "Python Tutorial

The above is the detailed content of How to use floor in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!