Using math module

>>> import math

>>> dir(math)

['__doc__', '__loader__', '__name__', '__package__', '__spec__', 'acos', 'acosh', 'asin', 'asinh', 'atan', 'atan2', 'atanh', 'ceil', 'copysign', 'cos', 'cosh', 'degrees', 'e', 'erf', 'erfc', 'exp', 'expm1', 'fabs', 'factorial', 'floor', 'fmod', 'frexp', 'fsum', 'gamma', 'gcd', 'hypot', 'inf', 'isclose', 'isfinite', 'isinf', 'isnan', 'ldexp', 'lgamma', 'log', 'log10', 'log1p', 'log2', 'modf', 'nan', 'pi', 'pow', 'radians', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tau', 'trunc']

>>> print(math.factorial(6))
720

>>> print(math.ceil(5.1))
6
>>> print(math.ceil(5.9))
6

>>> print(math.floor(5.1))
5

>>> print(math.pi)
3.141592653589793

>>> print(math.pow(2,3))
8.0

>>> print(math.sqrt(5))
2.23606797749979




Learn Python with Dr B P Sharma
Facebook: https://www.facebook.com/drbpsharma.in
Mobile    : +91 9810849501
Email      : bpsharma@gmail.com

Comments

Popular posts from this blog

Converting Excel File to JSON File using xlrd module

Using Oracle with Python

Using time module