math is a built-in module in python,it consists function like ceil(), floor() , sqrt() , pow(), pi etc.
ceil() function return ceiling value of number.
import math z=5.99 k=math.ceil(5/2) print("Ceiling value of z:",math.ceil(z)) print("Ceiling value of k:",k)
Ceiling value of z: 6 Ceiling value of k: 3
floor() function return floor value of number.
import math z=5.99 k=math.floor(5/2) print("floor value of z:",math.floor(z)) print("floor value of k:",k)
floor value of z: 5 floor value of k: 2
sqrt() function return square root of the number.
import math z=5 k=math.sqrt(7) print("Square root of z:",math.sqrt(z)) print("Square root of k:",k)
Square root of z: 2.23606797749979 Square root of k: 2.6457513110645907
pow() function return power of any number.
import math z=5 p=4 k=math.pow(7,3) print("Power of z to p:",math.pow(z,p)) print("Power of 7 to 3:",k)
Power of z to p: 625.0 Power of 7 to 3: 343.0
pi function return value of pi.
import math k=math.pi print("Value of Pi is:",math.pi) print("Value of Pi is:",k)
Value of Pi is: 3.141592653589793 Value of Pi is: 3.141592653589793
max() function return maximum value in a sequence and min() function return minimum value in a sequence.
max1=max(22,34,55,66) min1=min(22,34,55,66) list1=[12,23,54,23,53] list2=[12,23,54,23,53] print("Maximum value max1:",max1) print("Maximum value list1:",max(list1)) print("Minimum value min1:",min1) print("Minimum value list2:",min(list2))
Maximum value max1: 66 Maximum value list1: 54 Minimum value min1: 22 Minimum value list2: 12
abs() function return positive of any number.
k=abs(-4) p=-6 print("Absolute value of k is:",k) print("Absolute value of p is:",abs(p))
Absolute value of k is: 4 Absolute value of p is: 6