Latest web development tutorials

fonction de plancher de Python ()

chiffres Python chiffres Python


description

floor () Renvoie le nombre entier arrondi.


grammaire

Ce qui suit est la méthode plancher de syntaxe ():

import math

math.floor( x )

NOTE: floor () est pas directement accessible, nous avons besoin d'importer le module de mathématiques, invoquer la méthode par objet statique.


Paramètres

  • x - expression numérique.

Valeur de retour

Renvoie le nombre entier arrondi vers le bas.

Exemples

Le tableau suivant montre un exemple de l'utilisation de la méthode de plancher ():

#!/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)

Après avoir exécuté l'exemple ci-dessus est sortie:

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

chiffres Python chiffres Python