How to use the math module in Python

The math module in Python is a built-in module that provides access to mathematical functions. To use it, you first need to import the module:

import math

Once imported, you can access the various functions available in the module. For example, to calculate the square root of a number, you can use the sqrt() function:

x = 16

result = math.sqrt(x)

print(result)

# Output: 4.0