In [7]:
import math
In [16]:
pi = 3.14159
In [23]:
round(pi) # Redondeo integrado
Out[23]:
In [24]:
math.floor(pi) # Redondeo a la baja - Suelo
Out[24]:
In [25]:
math.floor(3.99)
Out[25]:
In [26]:
math.ceil(pi) # Redondeo al alta - Techo
Out[26]:
In [27]:
math.ceil(3.01)
Out[27]:
In [2]:
abs(-10)
Out[2]:
In [49]:
# Sumatorio integrado
n = [0.9999999, 1, 2, 3]
sum(n)
Out[49]:
In [48]:
# Sumatorio mejorado para números reales
math.fsum(n)
Out[48]:
In [55]:
math.trunc(123.45) # Truncar, cortar la parte decimal
Out[55]:
In [71]:
math.pow(2, 3) # Potencia con flotante
Out[71]:
In [73]:
2 ** 3 # Potencia directa
Out[73]:
In [64]:
math.sqrt(9) # Raíz cuadrada (square root)
Out[64]:
In [68]:
math.pi # Constante pi
Out[68]:
In [69]:
math.e # Constante e
Out[69]: