Skip to content

Math Module

import math as m

Command Description
m.ceil(x) ceil value
m.fabs(x) absolute value
m.factorial(x) factorial of x
m.floor(x) floor value of x
m.fmod(x)
m.frexp(x) (m,e) : x = m*2^e
m.fsum(mylist) returns accurate float sum
m.gcd(x, y) HCF of x and y
m.isnan(x) True if x is not a number
m.modf(5.33) (0.33999...9, 5.0)
m.remainder(x, y) x/y
m.exp(x) e^x
m.expm1(x) e^x - 1
m.log(x, base) if no base given then ln(x)
m.pow(x, y) x^y
m.sqrt(x) square root of x
m.degrees(x) radian to degree
m.radians(x) degree to radian

Constants

Command Description
m.pi 3.141592
m.e 2.718
m.tau 6.28318
m.inf inf
m.nan not a number