# It contains a set of built-in functions and a math module
# Used to perform various mathematical tasks on numbers
# For Ex – Finding minimum and maximum value among multiple numbers
x = min(5, 10, 25) # Use of built in math y = max(5, 10, 25) # functions print(x) print(y)
Output will be :
5
25
# For Ex – Getting Absolute ( Positive) and Power Values
x = abs(-7.25) print(x)
Output will be : 7.25
x = pow(4, 3) print(x)
Output will be : 64
# Use of math module functions
# For Ex - Calculating square root value of a number
import math x = math.sqrt(64) print(x)Output will be : 8
# For Ex – Getting the upward and downward nearest integer value of a real number
import math x = math.ceil(1.4) # Will return upward nearest number y = math.floor(1.4) # Will return downward nearest number print(x) print(y) Output will be:2 1
# For Ex – Getting the value of PI Constant
import math x = math.pi print(x)Output will be: 3.141592653589793
Note * : There are many more functions and constants available to use in math module
No comments:
Post a Comment