Python3 Función floor()

Python3 数字Números en Python3


Descripción

floor(x) devuelve el entero redondeado hacia abajo, menor o igual que x.


Sintaxis

A continuación se muestra la sintaxis del método floor():

import math

math.floor( x )

Nota:floor() no se puede acceder directamente; es necesario importar el módulo math y llamar a este método mediante un objeto estático.


Parámetros

  • x -- expresión numérica.

Valor de retorno

Devuelve un entero menor o igual que x.

Ejemplo

El siguiente ejemplo muestra el uso del método floor():

#!/usr/bin/python
import math   # 导入 math 模块

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(math.pi) : ", math.floor(math.pi))

El resultado de ejecutar el ejemplo anterior es:

math.floor(-45.17) :  -46
math.floor(100.12) :  100
math.floor(100.72) :  100
math.floor(math.pi) :  3

Python3 数字Números en Python3

Otras extensiones