Mathematical functions are defined in the math module. You will have to import the math module to get access to all its functions.
import math
#ceiling value
a = -52.3
print ("math ceil for ",a, " is : ", math.ceil(a))
print("********************")
#exponential value
a = 2
print("exponential value for ", a, " is: ",math.exp(2))
print("********************")
#absolute value of x
a = -98.4
print ("absolute value of ",a," is: ",abs(a))
print("********************")
#floor values
a = -98.4
print ("floor value for ",a," is: ", math.floor(a))
print("********************")
# log(x)
a = 10
print ("log value for ",a," is : ", math.log(a))
print("********************")
# log10(x)
a = 56
print ("log to the base 10 for ",a," is : ",math.log10(a))
print("********************")
# to the power of
a = 2
b = 3
print (a," to the power of ",b," is : ",math.pow(2,3))
print("********************")
# square root
a = 2
print("sqaure root")
print ("Square root of ",a," is : ", math.sqrt(25))
print("********************")
OUTPUT
math ceil for -52.3 is : -52
********************
exponential value for 2 is: 7.38905609893065
********************
absolute value of -98.4 is: 98.4
********************
floor value for -98.4 is: -99
********************
log value for 10 is : 2.302585092994046
********************
log to the base 10 for 56 is : 1.7481880270062005
********************
2 to the power of 3 is : 8.0
********************
sqaure root
Square root of 2 is : 5.0
********************
0 comments:
Post a Comment