Python comes with a collection of built-in math functions, as well as a substantial math module, that allows you to execute mathematical operations on numbers.
Built-in Math Functions
To determine the lowest or highest value in an iterable, use the min(>
and max(>
functions:
x = min(5, 10, 25>
y = max(5, 10, 25>
print(x>
print(y>
Output:
Try it here
The Math Module
Math is a built-in module in Python that adds to the set of mathematical functions.
You must first import the math module in order to utilise it:
After you've imported the math module, you may begin using its methods and constants.
For example, the math.sqrt(>
method returns the square root of a number:
import math
x = math.sqrt(81>
print(x>
Output: