Python Mathamatical Functions

Function

Returns ( description )

abs(x)

The absolute value of x: the (positive) distance between x and zero.

ceil(x)

The ceiling of x: the smallest integer not less than x

cmp(x, y)

-1 if x < y, 0 if x == y, or 1 if x > y

exp(x)

The exponential of x: ex

fabs(x)

The absolute value of x.

floor(x)

The floor of x: the largest integer not greater than x

log(x)

The natural logarithm of x, for x> 0

log10(x)

The base-10 logarithm of x for x> 0 .

max(x1, x2,...)

The largest of its arguments: the value closest to positive infinity

min(x1, x2,...)

The smallest of its arguments: the value closest to negative infinity

modf(x)

The fractional and integer parts of x in a two-item tuple. Both parts have the same sign as x. The integer part is returned as a float.

pow(x, y)

The value of x**y.

round(x [,n])

x rounded to n digits from the decimal point. Python rounds away from zero as a tie-breaker: round(0.5) is 1.0 and round(-0.5) is -1.0.

sqrt(x)

The square root of x for x > 0

 

Program on mathametical functions

import math
print(abs(-10))
print(math.ceil(4.344))
#print(cmp(4,3))
print(math.exp(300))
print(math.fabs(-30))
print(math.floor(3.65))
print(math.log(10))
print(math.log10(20))
print(max(23,44,33,22))
print(min(32,34,54,32,12,4))
print(math.modf(23))
print(math.pow(3,4))
print(round(3.543,1))
print(math.sqrt(25))

 

For
More Explanation
&
Online Classes

Contact Us:
+919885348743